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;