From a7b8ed7c4853c2e964462c348dded011f70ea1e3 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sun, 11 Jul 2021 13:01:56 +0200 Subject: [PATCH] #220 [profile] card images - show admin stats --- routes/admin.vue | 6 ++++++ server/cards.js | 2 +- src/stats.js | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/routes/admin.vue b/routes/admin.vue index c1b7e00fe..cdd9beb4d 100644 --- a/routes/admin.vue +++ b/routes/admin.vue @@ -84,6 +84,12 @@ +
+ + Images generated: + {{ stats.cards * 100 }}% +
+

diff --git a/server/cards.js b/server/cards.js index 40684c511..f74daaae8 100644 --- a/server/cards.js +++ b/server/cards.js @@ -27,7 +27,7 @@ const modes = ['light', 'dark']; LEFT JOIN users on profiles.userId = users.id WHERE profiles.card IS NULL ORDER BY RANDOM() - LIMIT 16 + LIMIT 8 `)).filter(({locale}) => !isHighLoadTime(locale)); if (profiles.length === 0) { diff --git a/src/stats.js b/src/stats.js index 3e61f5611..49a0ff5aa 100644 --- a/src/stats.js +++ b/src/stats.js @@ -108,5 +108,8 @@ module.exports.calculateStats = async (db, allLocales) => { }; } - return { calculatedAt: parseInt(new Date() / 1000), users, locales }; + const cardsCount = (await db.get(`SELECT 1.0 * (SELECT count(*) FROM profiles WHERE card IS NOT NULL) / (SELECT count(*) FROM profiles) as c`)).c; + const cards = Math.round(cardsCount * 1000) / 1000; + + return { calculatedAt: parseInt(new Date() / 1000), users, locales, cards }; }