From 6136dace7cf45a5da55fc7ed8731ac5baa76d5e5 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 20 Sep 2025 20:02:28 +0200 Subject: [PATCH] Fix null deref in updateRecords --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; }