user aliases
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 18s

This commit is contained in:
Flummi 2024-06-28 06:31:06 +02:00
parent e20e9899f9
commit 65818c2f40

View File

@ -26,12 +26,13 @@ export default {
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 user_alias on user_alias.alias = lower("items".username)
where
${ db.unsafe(modequery) }
and items.active = 'true'
${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` }
${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` }
${ !o.fav && user ? db`and items.username ilike ${'%'+user+'%'}` : db`` }
${ !o.fav && user ? db`and (items.username ilike ${'%'+user+'%'} or items.username ilike user_alias.alias)` : db`` }
${ mime ? db`and items.mime ilike ${smime}` : db`` }
${ !o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db`` }
group by items.id, tags.tag
@ -59,13 +60,14 @@ export default {
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 user_alias on user_alias.alias = lower("items".username)
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) }
and items.active = 'true'
${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` }
${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` }
${ !o.fav && user ? db`and items.username ilike ${'%'+user+'%'}` : db`` }
${ !o.fav && user ? db`and (items.username ilike ${'%'+user+'%'} or items.username ilike user_alias.alias)` : db`` }
${ mime ? db`and items.mime ilike ${smime}` : db`` }
${ !o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db`` }
group by items.id, tags.tag, ta.tag_id
@ -121,13 +123,14 @@ export default {
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 user_alias on user_alias.alias = lower("items".username)
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) }
and items.active = 'true'
${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` }
${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` }
${ !o.fav && user ? db`and items.username ilike ${'%'+user+'%'}` : db`` }
${ !o.fav && user ? db`and (items.username ilike ${'%'+user+'%'} or items.username ilike user_alias.alias)` : db`` }
${ mime ? db`and items.mime ilike ${smime}` : db`` }
${ !o.session && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db`` }
group by items.id, tags.tag, ta.tag_id