diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs
index 34313e1..4bac490 100644
--- a/src/inc/routes/index.mjs
+++ b/src/inc/routes/index.mjs
@@ -228,5 +228,22 @@ export default (router, tpl) => {
res.redirect(`/${referer}`);
});
+ router.get(/^\/ranking/, async (req, res) => {
+ try {
+ const list = await sql('tags_assign')
+ .select('prefix', sql.raw('count(distinct tag_id, item_id) count'))
+ .groupBy('prefix')
+ .orderBy('count', 'desc');
+
+ const stats = await lib.countf0cks();
+
+ res.reply({
+ body: tpl.render('ranking', { list, stats, tmp: null }, req)
+ });
+ } catch(err) {
+ res.end(JSON.stringify(err.message));
+ }
+ });
+
return router;
};
diff --git a/views/ranking.html b/views/ranking.html
new file mode 100644
index 0000000..3ac2814
--- /dev/null
+++ b/views/ranking.html
@@ -0,0 +1,24 @@
+@include(main/header)
+
+
+ rank |
+ username |
+ # tagged f0cks |
+
+ @for(let i = 0; i < list.length; i++)
+
+ {{ i + 1 }} |
+ {!! list[i].prefix !!} |
+ {{ list[i].count }} |
+
+ @endfor
+
+
+
+ total | {{ stats.total }} |
+ tagged | {{ stats.tagged }} |
+ untagged | {{ stats.untagged }} |
+ SFW | {{ stats.sfw }} |
+ NSFW | {{ stats.nsfw }} |
+
+@include(main/footer)