fix: percent number coloring

This commit is contained in:
Mats Stottmeister 2025-06-10 14:50:46 +02:00
parent e9a59a68dc
commit 7deafe425c
No known key found for this signature in database
2 changed files with 31 additions and 3 deletions

View file

@ -200,6 +200,27 @@ router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (
}); });
heartbeatList[monitorID] = processedData; heartbeatList[monitorID] = processedData;
// Calculate uptime based only on actual daily data (not including missing days)
if (processedData.length > 0) {
// Get recent data (last 30 days worth of actual data)
const recentData = processedData.slice(-30);
let totalUp = 0;
let totalDown = 0;
recentData.forEach(day => {
if (day.dailyStats) {
totalUp += day.dailyStats.up;
totalDown += day.dailyStats.down;
}
});
const totalChecks = totalUp + totalDown;
uptimeList[`${monitorID}_24`] = totalChecks > 0 ? (totalUp / totalChecks) : 0;
} else {
uptimeList[`${monitorID}_24`] = 0;
}
} else { } else {
// Use regular heartbeat data (last 100 beats) // Use regular heartbeat data (last 100 beats)
let list = await R.getAll(` let list = await R.getAll(`
@ -213,10 +234,10 @@ router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (
list = R.convertToBeans("heartbeat", list); list = R.convertToBeans("heartbeat", list);
heartbeatList[monitorID] = list.reverse().map(row => row.toPublicJSON()); heartbeatList[monitorID] = list.reverse().map(row => row.toPublicJSON());
}
const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID); const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID);
uptimeList[`${monitorID}_24`] = uptimeCalculator.get24Hour().uptime; uptimeList[`${monitorID}_24`] = uptimeCalculator.get24Hour().uptime;
}
} }
response.json({ response.json({

View file

@ -785,6 +785,13 @@ export default {
if (dailyViewSettings[monitorId]) { if (dailyViewSettings[monitorId]) {
// This monitor uses daily view // This monitor uses daily view
this.$root.dailyHeartbeatList[monitorId] = heartbeatList[monitorId]; this.$root.dailyHeartbeatList[monitorId] = heartbeatList[monitorId];
// Set up lastHeartbeatList for uptime color calculation
if (heartbeatList[monitorId] && heartbeatList[monitorId].length > 0) {
const lastDailyBeat = heartbeatList[monitorId][heartbeatList[monitorId].length - 1];
// Create a minimal heartbeat list with just the last beat for color calculation
this.$root.heartbeatList[monitorId] = [lastDailyBeat];
}
} else { } else {
// This monitor uses regular view // This monitor uses regular view
this.$root.heartbeatList[monitorId] = heartbeatList[monitorId]; this.$root.heartbeatList[monitorId] = heartbeatList[monitorId];