From 2df722f460fa0dee31128f501f33863456c2f3ee Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Sun, 8 Sep 2024 14:34:10 +0200 Subject: [PATCH] fix --- idp/src/application/user/user.service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/idp/src/application/user/user.service.ts b/idp/src/application/user/user.service.ts index 41885f8..dfffb84 100644 --- a/idp/src/application/user/user.service.ts +++ b/idp/src/application/user/user.service.ts @@ -24,8 +24,8 @@ export class UserService { order: { timestamp: 'asc' }, }); - const first = logs[0].timestamp; - const last = logs[logs.length - 1].timestamp; + const first = new Date(logs[0].timestamp.toISOString()); + const last = logs[logs.length - 1].timestamp.toISOString().substring(0, 10); const res = {}; @@ -36,13 +36,15 @@ export class UserService { if (logs.length > 1) { const current = first; - while (current <= last) { - current.setDate(current.getDate() + 1); + + while (current.toISOString().substring(0, 10) <= last) { res[current.toISOString().substring(0, 10)] = { logins: 0, systemLogins: 0, }; + current.setDate(current.getDate() + 1); } + logs.forEach((l) => { if (l.type == 'login') { res[l.timestamp.toISOString().substring(0, 10)].logins += 1;