fix rating and fav

This commit is contained in:
2026-08-13 21:14:20 +02:00
parent 402a043b57
commit 9ec07e8e6c
9 changed files with 53 additions and 17 deletions

View File

@@ -115,10 +115,13 @@ export default (router, tpl) => {
try {
const slug = '%' + lib.slugify(q) + '%';
const rows = await db`
SELECT t.tag, t.normalized, COUNT(ta.item_id) as uses
SELECT t.tag, t.normalized, COUNT(DISTINCT items.id) as uses
FROM tags t
JOIN tags_assign ta ON ta.tag_id = t.id
JOIN items ON items.id = ta.item_id
WHERE t.id > 2
AND items.active = true
AND items.is_deleted = false
AND lower(t.normalized) ILIKE ${slug}
GROUP BY t.tag, t.normalized
ORDER BY uses DESC