add counter how many items are hidden from public

This commit is contained in:
2026-06-19 14:47:08 +02:00
parent 8a24564cd9
commit 17ee7a3b2d
2 changed files with 21 additions and 2 deletions

View File

@@ -30,7 +30,17 @@ export default (router, tpl) => {
: [];
const tagMap = Object.fromEntries(tagRows.map(r => [r.id, r]));
const enriched = ids.map(id => tagMap[id] || { id, tag: '(unknown)', normalized: null });
return res.json({ success: true, nsfp: enriched, raw_ids: ids });
const blockedCount = ids.length > 0
? Number((await db`
SELECT COUNT(DISTINCT item_id) AS cnt
FROM tags_assign
WHERE tag_id IN ${db(ids)}
AND item_id IN (SELECT id FROM items WHERE active = true)
`)[0].cnt)
: 0;
return res.json({ success: true, nsfp: enriched, raw_ids: ids, blocked_count: blockedCount });
} catch (err) {
return res.json({ success: false, msg: err.message }, 500);
}