[admin][bug] don't count abuse reports for removed accounts

This commit is contained in:
Andrea Vos 2023-03-30 23:55:00 +02:00
parent 65c2f68f7f
commit 6bc43d8178
2 changed files with 4 additions and 1 deletions

View File

@ -407,6 +407,7 @@ router.get('/admin/reports', handleErrorAsync(async (req, res) => {
LEFT JOIN users reporter ON reports.reporterId = reporter.id
LEFT JOIN profiles p on sus.id = p.userId
WHERE reports.id > ${cutoff}
AND sus.username IS NOT NULL
GROUP BY reports.id
ORDER BY min(reports.isHandled) ASC, reports.id DESC
`));

View File

@ -152,7 +152,9 @@ module.exports.calculateStats = async (db, allLocales, projectDir) => {
users: (await db.get(`SELECT count(*) AS c FROM users`)).c,
data: {
admins: (await db.get(`SELECT count(*) AS c FROM users WHERE roles!=''`)).c,
userReports: (await db.get(`SELECT count(*) AS c FROM reports WHERE isHandled = 0`)).c,
userReports: (await db.get(`SELECT count(*) AS c FROM reports
LEFT JOIN users sus ON reports.userId = sus.id
WHERE isHandled = 0 AND sus.username IS NOT NULL`)).c,
bansPending: (await db.get(`SELECT count(*) AS c FROM ban_proposals p LEFT JOIN users u ON p.userId = u.id WHERE u.bannedBy IS NULL`)).c,
heartbeat: heartbeat['https://pronouns.page'],
plausible: await checkPlausible('https://pronouns.page'),