diff --git a/index.js b/index.js index c2d6c04..0a7dcce 100644 --- a/index.js +++ b/index.js @@ -86,14 +86,15 @@ function getSystemUptime() { */ function updateRecords(callStats, records) { const yesterday = getYesterday().startDate; + const yesterdayDateString = yesterday.toISOString().split('T')[0]; let isNewRecord = false; // Update all-time record - const allTimeRecord = records.callRecord || new CallRecord({ date: yesterday, count: 0 }); + const allTimeRecord = records.callRecord || new CallRecord({ date: yesterdayDateString, count: 0 }); if (!records.callRecord) { - records.callRecord = { date: currentDate, count: callStats.totalCallsMade }; + records.callRecord = { date: yesterdayDateString, count: callStats.totalCallsMade }; isNewRecord = true; - } else if (parseInt(allTimeRecord.count) < callStats.totalCallsThisMonth) { + } else if (allTimeRecord.count < callStats.totalCallsThisMonth) { allTimeRecord.count = callStats.totalCallsThisMonth; isNewRecord = true; }