diff --git a/src/inc/routes/toptags.mjs b/src/inc/routes/toptags.mjs index 47713b3..7f4252d 100644 --- a/src/inc/routes/toptags.mjs +++ b/src/inc/routes/toptags.mjs @@ -1,7 +1,5 @@ import db from "../../inc/sql.mjs"; import cfg from "../../inc/config.mjs"; -import lib from "../../inc/lib.mjs"; -import f0cklib from "../routeinc/f0cklib.mjs"; export default (router, tpl) => { router.get(/^\/tags$/, async (req, res) => { @@ -20,9 +18,21 @@ export default (router, tpl) => { 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({ body: tpl.render('tags', { toptags, + toptags_regged, phrase, tmp: null }, req) diff --git a/views/tags.html b/views/tags.html index 7fa70c3..f9c1e4a 100644 --- a/views/tags.html +++ b/views/tags.html @@ -3,15 +3,25 @@

- @each(toptags as toptag) + @if(session) + @each(toptags_regged as toptag)
-
{!! toptag.tag !!} {{ toptag.total_items }}
@endeach + @else + @each(toptags as toptag) +
+
+ {!! toptag.tag !!} + {{ toptag.total_items }} +
+
+ @endeach + @endif