active system count

This commit is contained in:
Luke Berndt
2024-08-29 22:16:06 -04:00
parent edf99e1162
commit a05519acef

View File

@@ -12,12 +12,14 @@ var spots = (24 * 60) / timePeriod; // the number of spots needed to keep track
async function updateActiveSystems() { async function updateActiveSystems() {
// Go through all of the Systems // Go through all of the Systems
let siteTotal = 0; let siteTotal = 0;
let activeSystems = 0;
for await (let item of System.find()) { for await (let item of System.find()) {
// go through all the systems // go through all the systems
// if you have received some calls during that last period, make the system active // if you have received some calls during that last period, make the system active
if ((callTotals[item.shortName] != undefined) && (callTotals[item.shortName] > 0)) { if ((callTotals[item.shortName] != undefined) && (callTotals[item.shortName] > 0)) {
item.active = true; item.active = true;
siteTotal += callTotals[item.shortName]; siteTotal += callTotals[item.shortName];
activeSystems++;
item.callAvg = callTotals[item.shortName] / timePeriod; item.callAvg = callTotals[item.shortName] / timePeriod;
item.lastActive = new Date(); item.lastActive = new Date();
} else { } else {
@@ -35,6 +37,7 @@ async function updateActiveSystems() {
await item.save(); await item.save();
}; };
console.log("Site average uploads per minute: " + siteTotal / timePeriod); console.log("Site average uploads per minute: " + siteTotal / timePeriod);
console.log("Active Systems: " + activeSystems);
} }
exports.initStats = async function () { exports.initStats = async function () {