Fix null deref in updateRecords
This commit is contained in:
parent
464ee153af
commit
6136dace7c
7
index.js
7
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue