use order by

isekai-main
Barış Soner Uşaklı 2 years ago
parent 77b05b73a8
commit 2cdc454f3e

@ -290,7 +290,7 @@ PARALLEL SAFE`);
if (!res.rows[0].d) {
await client.query(`
CREATE FUNCTION "nodebb_get_sorted_set_members_withscores"(TEXT) RETURNS JSON AS $$
SELECT json_agg(json_build_object('value', z."value", 'score', z."score")) as item
SELECT json_agg(json_build_object('value', z."value", 'score', z."score") ORDER BY z."score" ASC) as item
FROM "legacy_object_live" o
INNER JOIN "legacy_zset" z
ON o."_key" = z."_key"

@ -492,12 +492,6 @@ SELECT "_key" k,
FROM UNNEST($1::TEXT[]) "_key";`,
values: [keys],
});
// TODO: move this sort into nodebb_get_sorted_set_members_withscores?
res.rows.forEach((r) => {
if (r && r.m) {
r.m.sort((a, b) => a.score - b.score);
}
});
return keys.map(k => (res.rows.find(r => r.k === k) || {}).m || []);
};

Loading…
Cancel
Save