displaying all tags for logged in users, not applying nsfp list

This commit is contained in:
x 2025-05-01 14:59:28 +02:00
parent 4260a7429a
commit 0c96c258ab
2 changed files with 24 additions and 4 deletions

View File

@ -1,7 +1,5 @@
import db from "../../inc/sql.mjs"; import db from "../../inc/sql.mjs";
import cfg from "../../inc/config.mjs"; import cfg from "../../inc/config.mjs";
import lib from "../../inc/lib.mjs";
import f0cklib from "../routeinc/f0cklib.mjs";
export default (router, tpl) => { export default (router, tpl) => {
router.get(/^\/tags$/, async (req, res) => { router.get(/^\/tags$/, async (req, res) => {
@ -20,9 +18,21 @@ export default (router, tpl) => {
LIMIT 500 LIMIT 500
; ;
`; `;
const toptags_regged = await db`
SELECT t.id, t.tag, COUNT(DISTINCT ta.item_id) AS total_items
FROM tags t
LEFT JOIN tags_assign ta ON t.id = ta.tag_id
GROUP BY t.id, t.tag
ORDER BY total_items DESC
LIMIT 500
;
`;
res.reply({ res.reply({
body: tpl.render('tags', { body: tpl.render('tags', {
toptags, toptags,
toptags_regged,
phrase, phrase,
tmp: null tmp: null
}, req) }, req)

View File

@ -3,15 +3,25 @@
<div class="container"> <div class="container">
<h3 style="text-align: center;"></h3> <h3 style="text-align: center;"></h3>
<div class="tags"> <div class="tags">
@each(toptags as toptag) @if(session)
@each(toptags_regged as toptag)
<div class="tag badge badge-light mr-2"> <div class="tag badge badge-light mr-2">
<div class="tagbox-body"> <div class="tagbox-body">
<span class="toptag_id">{!! toptag.tag !!}</span> <span class="toptag_id">{!! toptag.tag !!}</span>
<span class="toptag_tag"><a href="/tag/{!! toptag.tag !!}">{{ toptag.total_items }}</a></span> <span class="toptag_tag"><a href="/tag/{!! toptag.tag !!}">{{ toptag.total_items }}</a></span>
</div> </div>
</div> </div>
@endeach @endeach
@else
@each(toptags as toptag)
<div class="tag badge badge-light mr-2">
<div class="tagbox-body">
<span class="toptag_id">{!! toptag.tag !!}</span>
<span class="toptag_tag"><a href="/tag/{!! toptag.tag !!}">{{ toptag.total_items }}</a></span>
</div>
</div>
@endeach
@endif
</div> </div>
</div> </div>
</div> </div>