oops
This commit is contained in:
parent
63e2d01feb
commit
0a9e5e274f
|
@ -154,14 +154,7 @@ const authRouter = (passport: PassportStatic) => {
|
|||
const users = (await getAllLingdocsUsers()).sort((a, b) => (
|
||||
(a.accountCreated || 0) - (b.accountCreated || 0)
|
||||
));
|
||||
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 });
|
||||
})
|
||||
));
|
||||
const tests = getTestCompletionSummary(users)
|
||||
res.render("admin", { users, tests });
|
||||
} catch (e) {
|
||||
next(e);
|
||||
|
@ -310,4 +303,16 @@ const authRouter = (passport: PassportStatic) => {
|
|||
return router;
|
||||
}
|
||||
|
||||
function getTestCompletionSummary(users: T.LingdocsUser[]) {
|
||||
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: 1 });
|
||||
})
|
||||
));
|
||||
return tests;
|
||||
}
|
||||
|
||||
export default authRouter;
|
Loading…
Reference in New Issue