add uptimePercentage to aggregate data

This commit is contained in:
Alex Holliday committed 2024-09-04 13:21:51 -07:00
1 parent 6424a0436f
commit 70a4058993
1 file changed
+2
+2
View File
@@ -212,6 +212,7 @@ const getMonitorStatsById = async (req) => {
// Map grouped checks to stats // Map grouped checks to stats
const aggregateData = Object.values(groupedChecks).map((group) => { const aggregateData = Object.values(groupedChecks).map((group) => {
const totalChecks = group.checks.length; const totalChecks = group.checks.length;
const uptimePercentage = getUptimePercentage(group.checks);
const totalIncidents = group.checks.filter( const totalIncidents = group.checks.filter(
(check) => check.status === false (check) => check.status === false
).length; ).length;
@@ -221,6 +222,7 @@ const getMonitorStatsById = async (req) => {
return { return {
time: group.time, time: group.time,
uptimePercentage,
totalChecks, totalChecks,
totalIncidents, totalIncidents,
avgResponseTime, avgResponseTime,