From 95d2369acc209a37e889ce25813ef1b3eb2fad72 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Sat, 9 Sep 2023 18:35:59 -0500 Subject: [PATCH] adds option to anonymize rentry stats --- src/admin/web/manage.ts | 9 +++++---- src/admin/web/views/admin_index.ejs | 3 ++- src/shared/views/partials/shared_header.ejs | 11 ++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/admin/web/manage.ts b/src/admin/web/manage.ts index 626fcb1..7a3c7fe 100644 --- a/src/admin/web/manage.ts +++ b/src/admin/web/manage.ts @@ -228,7 +228,7 @@ router.post("/maintenance", (req, res) => { return res.redirect(`/admin/manage`); }); -router.get("/rentry-stats", (_req, res) => { +router.get("/rentry-stats", (req, res) => { const users = userStore.getUsers(); let totalTokens = 0; @@ -245,9 +245,10 @@ router.get("/rentry-stats", (_req, res) => { totalIps += user.ip.length; const token = `...${user.token.slice(-5)}`; - const name = user.nickname - ? `${user.nickname.slice(0, 16).padEnd(16)} ${token}` - : `${"Anonymous".padEnd(16)} ${token}`; + const name = + user.nickname && !req.query.anon + ? `${user.nickname.slice(0, 16).padEnd(16)} ${token}` + : `${"Anonymous".padEnd(16)} ${token}`; const strUser = name.padEnd(25); const strPrompts = `${user.promptCount} proompts`.padEnd(14); const strIps = `${user.ip.length} IPs`.padEnd(8); diff --git a/src/admin/web/views/admin_index.ejs b/src/admin/web/views/admin_index.ejs index 74079b8..cd7d1fd 100644 --- a/src/admin/web/views/admin_index.ejs +++ b/src/admin/web/views/admin_index.ejs @@ -18,7 +18,8 @@
  • Create User
  • Import Users
  • Export Users
  • -
  • Download Rentry Stats
  • +
  • Download Rentry Stats | Anonymized
  • Maintenance

    diff --git a/src/shared/views/partials/shared_header.ejs b/src/shared/views/partials/shared_header.ejs index 267a7fb..af3b469 100644 --- a/src/shared/views/partials/shared_header.ejs +++ b/src/shared/views/partials/shared_header.ejs @@ -5,6 +5,14 @@ <%= title %>