mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-19 18:56:48 +02:00
fix range 30-90 v2
This commit is contained in:
parent
8b2bf8a8c8
commit
1f4c4a0cb1
1 changed files with 11 additions and 4 deletions
|
@ -271,8 +271,13 @@ async function getAggregatedHeartbeats(uptimeCalculator, days) {
|
||||||
const startTime = now.subtract(days, "day");
|
const startTime = now.subtract(days, "day");
|
||||||
const totalMinutes = endTime.diff(startTime, "minute");
|
const totalMinutes = endTime.diff(startTime, "minute");
|
||||||
|
|
||||||
// Always create exactly 100 buckets spanning the full time range
|
// Calculate optimal bucket count based on available data granularity
|
||||||
const numBuckets = 100;
|
// For longer periods with daily data, use fewer buckets to match available data points
|
||||||
|
let numBuckets = 100;
|
||||||
|
if (days > 30) {
|
||||||
|
// For daily data, limit buckets to available data points to prevent sparse data
|
||||||
|
numBuckets = Math.min(100, Math.max(50, days));
|
||||||
|
}
|
||||||
const bucketSizeMinutes = totalMinutes / numBuckets;
|
const bucketSizeMinutes = totalMinutes / numBuckets;
|
||||||
|
|
||||||
// Get available data from UptimeCalculator for lookup
|
// Get available data from UptimeCalculator for lookup
|
||||||
|
@ -282,11 +287,13 @@ async function getAggregatedHeartbeats(uptimeCalculator, days) {
|
||||||
if (days <= 1) {
|
if (days <= 1) {
|
||||||
const exactMinutes = Math.ceil(days * 24 * 60);
|
const exactMinutes = Math.ceil(days * 24 * 60);
|
||||||
rawDataPoints = uptimeCalculator.getDataArray(exactMinutes, "minute");
|
rawDataPoints = uptimeCalculator.getDataArray(exactMinutes, "minute");
|
||||||
} else if (days <= 90) {
|
} else if (days <= 30) {
|
||||||
const exactHours = Math.ceil(days * 24);
|
const exactHours = Math.ceil(days * 24);
|
||||||
rawDataPoints = uptimeCalculator.getDataArray(exactHours, "hour");
|
rawDataPoints = uptimeCalculator.getDataArray(exactHours, "hour");
|
||||||
} else {
|
} else {
|
||||||
rawDataPoints = uptimeCalculator.getDataArray(days, "day");
|
// For > 30 days, use daily data to avoid hitting the 720-hour limit
|
||||||
|
const requestDays = Math.min(days, 365);
|
||||||
|
rawDataPoints = uptimeCalculator.getDataArray(requestDays, "day");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create lookup map for available data
|
// Create lookup map for available data
|
||||||
|
|
Loading…
Add table
Reference in a new issue