simplify offering/seeking count query
This commit is contained in:
parent
68e6e9e243
commit
f1a8277c22
1 changed files with 3 additions and 4 deletions
|
@ -400,10 +400,9 @@ const buildItemTradeCountsLoader = (db) =>
|
||||||
const [rows, _] = await db.execute(
|
const [rows, _] = await db.execute(
|
||||||
`
|
`
|
||||||
SELECT
|
SELECT
|
||||||
items.id AS item_id, closet_hangers.owned AS is_owned,
|
closet_hangers.item_id AS item_id, closet_hangers.owned AS is_owned,
|
||||||
count(DISTINCT closet_hangers.user_id) AS users_count
|
count(DISTINCT closet_hangers.user_id) AS users_count
|
||||||
FROM items
|
FROM closet_hangers
|
||||||
INNER JOIN closet_hangers ON closet_hangers.item_id = items.id
|
|
||||||
INNER JOIN users ON users.id = closet_hangers.user_id
|
INNER JOIN users ON users.id = closet_hangers.user_id
|
||||||
LEFT JOIN closet_lists ON closet_lists.id = closet_hangers.list_id
|
LEFT JOIN closet_lists ON closet_lists.id = closet_hangers.list_id
|
||||||
WHERE (
|
WHERE (
|
||||||
|
@ -420,7 +419,7 @@ const buildItemTradeCountsLoader = (db) =>
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
GROUP BY items.id, closet_hangers.owned;
|
GROUP BY closet_hangers.item_id, closet_hangers.owned;
|
||||||
`,
|
`,
|
||||||
values
|
values
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue