Add support for sending stats to Matrix, split out some code into more generic classes. #1
7
index.js
7
index.js
|
@ -86,14 +86,15 @@ function getSystemUptime() {
|
||||||
*/
|
*/
|
||||||
function updateRecords(callStats, records) {
|
function updateRecords(callStats, records) {
|
||||||
const yesterday = getYesterday().startDate;
|
const yesterday = getYesterday().startDate;
|
||||||
|
const yesterdayDateString = yesterday.toISOString().split('T')[0];
|
||||||
let isNewRecord = false;
|
let isNewRecord = false;
|
||||||
|
|
||||||
// Update all-time record
|
// 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) {
|
if (!records.callRecord) {
|
||||||
records.callRecord = { date: currentDate, count: callStats.totalCallsMade };
|
records.callRecord = { date: yesterdayDateString, count: callStats.totalCallsMade };
|
||||||
isNewRecord = true;
|
isNewRecord = true;
|
||||||
} else if (parseInt(allTimeRecord.count) < callStats.totalCallsThisMonth) {
|
} else if (allTimeRecord.count < callStats.totalCallsThisMonth) {
|
||||||
allTimeRecord.count = callStats.totalCallsThisMonth;
|
allTimeRecord.count = callStats.totalCallsThisMonth;
|
||||||
isNewRecord = true;
|
isNewRecord = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue