mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-18 23:34:04 +02:00
fix: percent number coloring
This commit is contained in:
parent
e9a59a68dc
commit
7deafe425c
2 changed files with 31 additions and 3 deletions
|
@ -200,6 +200,27 @@ router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (
|
|||
});
|
||||
|
||||
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 {
|
||||
// Use regular heartbeat data (last 100 beats)
|
||||
let list = await R.getAll(`
|
||||
|
@ -213,11 +234,11 @@ router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (
|
|||
|
||||
list = R.convertToBeans("heartbeat", list);
|
||||
heartbeatList[monitorID] = list.reverse().map(row => row.toPublicJSON());
|
||||
}
|
||||
|
||||
const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID);
|
||||
uptimeList[`${monitorID}_24`] = uptimeCalculator.get24Hour().uptime;
|
||||
}
|
||||
}
|
||||
|
||||
response.json({
|
||||
heartbeatList,
|
||||
|
|
|
@ -785,6 +785,13 @@ export default {
|
|||
if (dailyViewSettings[monitorId]) {
|
||||
// This monitor uses daily view
|
||||
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 {
|
||||
// This monitor uses regular view
|
||||
this.$root.heartbeatList[monitorId] = heartbeatList[monitorId];
|
||||
|
|
Loading…
Add table
Reference in a new issue