This commit is contained in:
Flummi 2021-12-23 06:07:23 +01:00
parent 885d729a76
commit 17006f7e10
2 changed files with 41 additions and 0 deletions

View File

@ -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;
};

24
views/ranking.html Normal file
View File

@ -0,0 +1,24 @@
@include(main/header)
<table>
<tr>
<td>rank</td>
<td>username</td>
<td># tagged f0cks</td>
</tr>
@for(let i = 0; i < list.length; i++)
<tr>
<td>{{ i + 1 }}</td>
<td>{!! list[i].prefix !!}</td>
<td>{{ list[i].count }}</td>
</tr>
@endfor
</table>
<hr />
<table>
<tr><td>total</td><td>{{ stats.total }}</td></tr>
<tr><td>tagged</td><td>{{ stats.tagged }}</td></tr>
<tr><td>untagged</td><td>{{ stats.untagged }}</td></tr>
<tr><td>SFW</td><td>{{ stats.sfw }}</td></tr>
<tr><td>NSFW</td><td>{{ stats.nsfw }}</td></tr>
</table>
@include(main/footer)