#220 [profile] card images - show admin stats

This commit is contained in:
Andrea Vos 2021-07-11 13:01:56 +02:00
parent a5b0c8b866
commit a7b8ed7c48
3 changed files with 11 additions and 2 deletions

View File

@ -84,6 +84,12 @@
<ChartSet name="users" :data="stats.users.chart" init="cumulative"/>
<section>
<Icon v="id-card"/>
Images generated:
{{ stats.cards * 100 }}%
</section>
<section v-if="$isGranted('users') && suspiciousUsers.length > 0">
<h3>
<Icon v="siren-on"/>

View File

@ -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) {

View File

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