From 6bc43d8178296220af5e24b1f1d440c39b6eabb7 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Thu, 30 Mar 2023 23:55:00 +0200 Subject: [PATCH] [admin][bug] don't count abuse reports for removed accounts --- server/routes/admin.js | 1 + src/stats.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/routes/admin.js b/server/routes/admin.js index b09c7b0ee..b3d23f9c4 100644 --- a/server/routes/admin.js +++ b/server/routes/admin.js @@ -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 `)); diff --git a/src/stats.js b/src/stats.js index a5579774f..06b683efc 100644 --- a/src/stats.js +++ b/src/stats.js @@ -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'),