This commit is contained in:
Bastian Wagner
2024-09-08 14:34:10 +02:00
parent 71458067d8
commit 2df722f460

View File

@@ -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;