From da6b310449cf618f4a9a5a0b9b47b7ec723ed25f Mon Sep 17 00:00:00 2001 From: Flummi Date: Mon, 3 Jan 2022 20:49:53 +0100 Subject: [PATCH] hoster in ranking --- src/inc/routes/index.mjs | 15 ++++++++++++++- views/ranking.html | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index d27695d..15fa5b8 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -72,8 +72,21 @@ export default (router, tpl) => { const stats = await lib.countf0cks(); + const hoster = await sql.with('t', sql.raw("select split_part(substring(src, position('//' in src)+2), '/', 1) part from items")) + .from('t') + .select('t.part') + .count('t.part as c') + .groupBy('t.part') + .orderBy('c', 'desc') + .limit(10); + res.reply({ - body: tpl.render('ranking', { list, stats, tmp: null }, req) + body: tpl.render('ranking', { + list, + stats, + hoster, + tmp: null + }, req) }); } catch(err) { res.end(JSON.stringify(err.message)); diff --git a/views/ranking.html b/views/ranking.html index 42f557d..da0084f 100644 --- a/views/ranking.html +++ b/views/ranking.html @@ -26,4 +26,13 @@ SFW{{ stats.sfw }} NSFW{{ stats.nsfw }} +
+ + @each(hoster as host) + + + + + @endeach +
{{ host.part }}{{ host.c }}
@include(snippets/footer)