ranking
This commit is contained in:
parent
885d729a76
commit
17006f7e10
|
@ -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
24
views/ranking.html
Normal 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)
|
Loading…
Reference in New Issue
Block a user