From d0f8cb5acb03ca6d2a6a654711472d352a94c413 Mon Sep 17 00:00:00 2001 From: Flummi Date: Sat, 21 May 2022 15:16:04 +0200 Subject: [PATCH] fix pagination --- src/inc/routeinc/f0cklib.mjs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/inc/routeinc/f0cklib.mjs b/src/inc/routeinc/f0cklib.mjs index a17c76e..4392f19 100644 --- a/src/inc/routeinc/f0cklib.mjs +++ b/src/inc/routeinc/f0cklib.mjs @@ -17,13 +17,12 @@ export default { const total = (await db` select distinct on (items.id) - count(*) as total + count(items.id) as total from items left join tags_assign on tags_assign.item_id = items.id left join tags on tags.id = tags_assign.tag_id left join favorites on favorites.item_id = items.id left join "user" on "user".id = favorites.user_id - left join tags_assign ta on ta.item_id = items.id and (ta.tag_id = 1 or ta.tag_id = 2) where ${ db.unsafe(modequery) } ${ tag ? db`and tags.normalized ilike ${'%'+tag+'%'}` : db`` } @@ -31,10 +30,10 @@ export default { ${ user ? db`and items.username ilike ${'%'+user+'%'}` : db`` } ${ mime ? db`and items.mime ilike ${smime}` : db`` } and items.id not in (select item_id from tags_assign where item_id = items.id and tag_id = 9912) --public filter - group by items.id, tags.tag, ta.tag_id - `)?.[0]?.total || 0; + group by items.id, tags.tag + `)?.length || 0; - if(!total || total.length === 0) { + if(!total || total === 0) { return { success: false, message: "404 - no f0cks given"