mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-19 10:46:48 +02:00
status page router ismplification getData
This commit is contained in:
parent
91221b5cb9
commit
5c6cf48a77
1 changed files with 6 additions and 14 deletions
|
@ -112,7 +112,6 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
||||||
|
|
||||||
list = R.convertToBeans("heartbeat", list);
|
list = R.convertToBeans("heartbeat", list);
|
||||||
heartbeats = list.reverse().map(row => row.toPublicJSON());
|
heartbeats = list.reverse().map(row => row.toPublicJSON());
|
||||||
uptime = uptimeCalculator.get24Hour().uptime;
|
|
||||||
} else {
|
} else {
|
||||||
// For configured day ranges, use aggregated data from UptimeCalculator
|
// For configured day ranges, use aggregated data from UptimeCalculator
|
||||||
const buckets = uptimeCalculator.getAggregatedBuckets(heartbeatBarDays, maxBeats);
|
const buckets = uptimeCalculator.getAggregatedBuckets(heartbeatBarDays, maxBeats);
|
||||||
|
@ -125,20 +124,13 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
||||||
msg: "",
|
msg: "",
|
||||||
ping: null
|
ping: null
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate uptime for the exact configured range
|
// Calculate uptime based on the range
|
||||||
try {
|
if (heartbeatBarDays <= 1) {
|
||||||
uptime = uptimeCalculator.getDataByDuration(`${heartbeatBarDays}d`).uptime;
|
uptime = uptimeCalculator.get24Hour().uptime;
|
||||||
} catch (e) {
|
} else {
|
||||||
// Fall back to available ranges if duration exceeds limits
|
uptime = uptimeCalculator.getData(heartbeatBarDays, "day").uptime;
|
||||||
if (heartbeatBarDays <= 1) {
|
|
||||||
uptime = uptimeCalculator.get24Hour().uptime;
|
|
||||||
} else if (heartbeatBarDays <= 30) {
|
|
||||||
uptime = uptimeCalculator.get30Day().uptime;
|
|
||||||
} else {
|
|
||||||
uptime = uptimeCalculator.get1Year().uptime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Reference in a new issue