Add empty checks if there are less than 60 mins worth of cehcks
This commit is contained in:
1 parent
7336287a9c
commit
801f962af9
1 file changed
+17
-11
@@ -126,16 +126,22 @@ const getIncidents = (checks) => {
|
||||
* @param {Array} checks Array of check objects.
|
||||
* @returns {Array<Boolean>} Array of booleans representing up/down.
|
||||
*/
|
||||
const getStatusBarValues = (checks) => {
|
||||
return checks
|
||||
.map((check) => {
|
||||
return {
|
||||
status: check.status,
|
||||
responseTime: check.responseTime,
|
||||
value: 75,
|
||||
};
|
||||
})
|
||||
.reverse();
|
||||
const getStatusBarValues = (monitor, checks) => {
|
||||
const checksIn60Mins = Math.floor((60 * 60 * 1000) / monitor.interval);
|
||||
const noBlankChecks = checksIn60Mins - checks.length;
|
||||
|
||||
const statusBarValues = checks.map((check) => {
|
||||
return {
|
||||
status: check.status,
|
||||
responseTime: check.responseTime,
|
||||
value: 75,
|
||||
};
|
||||
});
|
||||
|
||||
for (let i = 0; i < noBlankChecks; i++) {
|
||||
statusBarValues.push({ status: false, responseTime: 0, value: 0 });
|
||||
}
|
||||
return statusBarValues.reverse();
|
||||
};
|
||||
/**
|
||||
* Get stats by monitor ID
|
||||
@@ -211,7 +217,7 @@ const getMonitorStatsById = async (req) => {
|
||||
getAverageResponseTime24Hours(checks24Hours);
|
||||
monitorStats.uptime24Hours = getUptimePercentage(checks24Hours);
|
||||
monitorStats.uptime30Days = getUptimePercentage(checks30Days);
|
||||
monitorStats.statusBar = getStatusBarValues(checks60Mins);
|
||||
monitorStats.statusBar = getStatusBarValues(monitor, checks60Mins);
|
||||
}
|
||||
|
||||
//Get checks for dateRange
|
||||
|
||||
Reference in new issue
Block a user