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.
|
* @param {Array} checks Array of check objects.
|
||||||
* @returns {Array<Boolean>} Array of booleans representing up/down.
|
* @returns {Array<Boolean>} Array of booleans representing up/down.
|
||||||
*/
|
*/
|
||||||
const getStatusBarValues = (checks) => {
|
const getStatusBarValues = (monitor, checks) => {
|
||||||
return checks
|
const checksIn60Mins = Math.floor((60 * 60 * 1000) / monitor.interval);
|
||||||
.map((check) => {
|
const noBlankChecks = checksIn60Mins - checks.length;
|
||||||
return {
|
|
||||||
status: check.status,
|
const statusBarValues = checks.map((check) => {
|
||||||
responseTime: check.responseTime,
|
return {
|
||||||
value: 75,
|
status: check.status,
|
||||||
};
|
responseTime: check.responseTime,
|
||||||
})
|
value: 75,
|
||||||
.reverse();
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i = 0; i < noBlankChecks; i++) {
|
||||||
|
statusBarValues.push({ status: false, responseTime: 0, value: 0 });
|
||||||
|
}
|
||||||
|
return statusBarValues.reverse();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get stats by monitor ID
|
* Get stats by monitor ID
|
||||||
@@ -211,7 +217,7 @@ const getMonitorStatsById = async (req) => {
|
|||||||
getAverageResponseTime24Hours(checks24Hours);
|
getAverageResponseTime24Hours(checks24Hours);
|
||||||
monitorStats.uptime24Hours = getUptimePercentage(checks24Hours);
|
monitorStats.uptime24Hours = getUptimePercentage(checks24Hours);
|
||||||
monitorStats.uptime30Days = getUptimePercentage(checks30Days);
|
monitorStats.uptime30Days = getUptimePercentage(checks30Days);
|
||||||
monitorStats.statusBar = getStatusBarValues(checks60Mins);
|
monitorStats.statusBar = getStatusBarValues(monitor, checks60Mins);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get checks for dateRange
|
//Get checks for dateRange
|
||||||
|
|||||||
Reference in new issue
Block a user