From 4d654d00609b45243a957e8098265782a419bc5f Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Thu, 8 Sep 2022 11:43:56 +0400 Subject: [PATCH] more test info --- account/src/routers/auth-router.ts | 14 +++++++++----- account/views/admin.ejs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/account/src/routers/auth-router.ts b/account/src/routers/auth-router.ts index 5d373e8..fc29397 100644 --- a/account/src/routers/auth-router.ts +++ b/account/src/routers/auth-router.ts @@ -154,11 +154,15 @@ const authRouter = (passport: PassportStatic) => { const users = (await getAllLingdocsUsers()).sort((a, b) => ( (a.accountCreated || 0) - (b.accountCreated || 0) )); - const tests = new Set(); - users.forEach(u => u.tests.forEach(t => ( - tests.add(t.id) - ))); - res.render("admin", { users, tests: Array.from(tests) }); + const tests: { id: string, passes: number }[] = []; + users.forEach(u => ( + u.tests.forEach(({id}) => { + const ti = tests.findIndex(x => x.id === id); + if (ti > -1) tests[ti].passes++; + else tests.push({ id, passes: 0 }); + }) + )); + res.render("admin", { users, tests }); } catch (e) { next(e); } diff --git a/account/views/admin.ejs b/account/views/admin.ejs index cbdb144..49db6d0 100644 --- a/account/views/admin.ejs +++ b/account/views/admin.ejs @@ -103,7 +103,7 @@
Tests Completed
<% for(var i=0; i < tests.length; i++) { %> -
<%= tests[i] %>
+
<%= tests[i].id %>: <%= tests[i].passes =>
<% } %>