fix pagination
This commit is contained in:
parent
29d5b20f5b
commit
d0f8cb5acb
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user