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 tagMap = Object.fromEntries(tagRows.map(r => [r.id, r]));
const enriched = ids.map(id => tagMap[id] || { id, tag: '(unknown)', normalized: null }); 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) { } catch (err) {
return res.json({ success: false, msg: err.message }, 500); return res.json({ success: false, msg: err.message }, 500);
} }

View File

@@ -13,7 +13,10 @@
<!-- Current NSFP tags --> <!-- Current NSFP tags -->
<div style="background: rgba(0,0,0,0.15); border: 1px solid rgba(255,255,255,0.06); border-radius: 6px; padding: 20px; margin-bottom: 24px;"> <div style="background: rgba(0,0,0,0.15); border: 1px solid rgba(255,255,255,0.06); border-radius: 6px; padding: 20px; margin-bottom: 24px;">
<p style="font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: #888; margin: 0 0 8px;">Current NSFP Tags</p> <div style="display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px;">
<p style="font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: #888; margin: 0;">Current NSFP Tags</p>
<span id="nsfp-blocked-stat" style="font-size: 0.8em; color: #888;"></span>
</div>
<div class="nsfp-chips-area" id="nsfp-chips"> <div class="nsfp-chips-area" id="nsfp-chips">
<span class="nsfp-chips-empty">Loading&hellip;</span> <span class="nsfp-chips-empty">Loading&hellip;</span>
</div> </div>
@@ -129,6 +132,12 @@
emptyEl.textContent = 'No NSFP tags configured \u2014 all content is public.'; emptyEl.textContent = 'No NSFP tags configured \u2014 all content is public.';
chipsEl.appendChild(emptyEl); chipsEl.appendChild(emptyEl);
} }
var statEl = document.getElementById('nsfp-blocked-stat');
if (statEl) {
var n = data.blocked_count || 0;
statEl.textContent = n.toLocaleString() + ' item' + (n !== 1 ? 's' : '') + ' hidden from guests';
statEl.style.color = n > 0 ? 'var(--accent)' : '#888';
}
}) })
.catch(function (e) { .catch(function (e) {
chipsEl.innerHTML = '<span class="nsfp-chips-empty" style="color:#d9534f;">Failed to load: ' + escapeHtml(e.message) + '</span>'; chipsEl.innerHTML = '<span class="nsfp-chips-empty" style="color:#d9534f;">Failed to load: ' + escapeHtml(e.message) + '</span>';