mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-19 18:56:48 +02:00
cleaned up debugging
This commit is contained in:
parent
e16b6cf0d1
commit
94adf2c9d4
3 changed files with 0 additions and 29 deletions
|
@ -89,8 +89,6 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
||||||
let statusPage = await R.findOne("status_page", " id = ? ", [ statusPageID ]);
|
let statusPage = await R.findOne("status_page", " id = ? ", [ statusPageID ]);
|
||||||
let heartbeatRange = statusPage ? statusPage.heartbeat_bar_range : "auto";
|
let heartbeatRange = statusPage ? statusPage.heartbeat_bar_range : "auto";
|
||||||
|
|
||||||
console.log(`[STATUS-PAGE] Processing ${monitorIDList.length} monitors with range: ${heartbeatRange}`);
|
|
||||||
|
|
||||||
for (let monitorID of monitorIDList) {
|
for (let monitorID of monitorIDList) {
|
||||||
let list;
|
let list;
|
||||||
|
|
||||||
|
@ -99,11 +97,9 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
||||||
|
|
||||||
if (aggregatedData) {
|
if (aggregatedData) {
|
||||||
// Use pre-aggregated stat data
|
// Use pre-aggregated stat data
|
||||||
console.log(`[STATUS-PAGE] Using aggregated data for monitor ${monitorID}: ${aggregatedData.length} records`);
|
|
||||||
heartbeatList[monitorID] = aggregatedData;
|
heartbeatList[monitorID] = aggregatedData;
|
||||||
} else {
|
} else {
|
||||||
// Fall back to raw heartbeat data (auto mode or no stat data)
|
// Fall back to raw heartbeat data (auto mode or no stat data)
|
||||||
console.log(`[STATUS-PAGE] Using raw heartbeat data for monitor ${monitorID} (range: ${heartbeatRange})`);
|
|
||||||
|
|
||||||
if (heartbeatRange === "auto") {
|
if (heartbeatRange === "auto") {
|
||||||
// Auto mode - use original LIMIT 100 logic
|
// Auto mode - use original LIMIT 100 logic
|
||||||
|
@ -122,7 +118,6 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
||||||
date.setHours(date.getHours() - hours);
|
date.setHours(date.getHours() - hours);
|
||||||
const dateFrom = date.toISOString().slice(0, 19).replace('T', ' ');
|
const dateFrom = date.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
console.log(`[STATUS-PAGE] Filtering heartbeat data from ${dateFrom} for ${hours} hours`);
|
|
||||||
|
|
||||||
list = await R.getAll(`
|
list = await R.getAll(`
|
||||||
SELECT * FROM heartbeat
|
SELECT * FROM heartbeat
|
||||||
|
@ -136,7 +131,6 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques
|
||||||
|
|
||||||
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());
|
||||||
console.log(`[STATUS-PAGE] Raw heartbeat data for monitor ${monitorID}: ${heartbeatList[monitorID].length} records`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID);
|
const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID);
|
||||||
|
|
|
@ -32,35 +32,26 @@ function parseRangeHours(range) {
|
||||||
* @returns {Promise<Array>} Aggregated heartbeat data
|
* @returns {Promise<Array>} Aggregated heartbeat data
|
||||||
*/
|
*/
|
||||||
async function getAggregatedHeartbeatData(monitorId, range) {
|
async function getAggregatedHeartbeatData(monitorId, range) {
|
||||||
console.log(`[HEARTBEAT-RANGE] Getting aggregated data for monitor ${monitorId}, range: ${range}`);
|
|
||||||
|
|
||||||
if (!range || range === "auto") {
|
if (!range || range === "auto") {
|
||||||
console.log(`[HEARTBEAT-RANGE] Auto mode - returning null to use regular heartbeat query`);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
const hours = parseRangeHours(range);
|
const hours = parseRangeHours(range);
|
||||||
console.log(`[HEARTBEAT-RANGE] Parsed ${range} to ${hours} hours`);
|
|
||||||
|
|
||||||
if (hours <= 24) {
|
if (hours <= 24) {
|
||||||
// Use hourly stats for ranges up to 24 hours
|
// Use hourly stats for ranges up to 24 hours
|
||||||
const startTime = now.subtract(hours, "hours");
|
const startTime = now.subtract(hours, "hours");
|
||||||
const timestampKey = Math.floor(startTime.valueOf() / (60 * 60 * 1000)); // Convert to seconds
|
const timestampKey = Math.floor(startTime.valueOf() / (60 * 60 * 1000)); // Convert to seconds
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-RANGE] Using hourly stats from timestamp ${timestampKey} (${dayjs(timestampKey * 1000).format()})`);
|
|
||||||
|
|
||||||
const stats = await R.getAll(`
|
const stats = await R.getAll(`
|
||||||
SELECT * FROM stat_hourly
|
SELECT * FROM stat_hourly
|
||||||
WHERE monitor_id = ? AND timestamp >= ?
|
WHERE monitor_id = ? AND timestamp >= ?
|
||||||
ORDER BY timestamp ASC
|
ORDER BY timestamp ASC
|
||||||
`, [monitorId, timestampKey]);
|
`, [monitorId, timestampKey]);
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-RANGE] Found ${stats.length} hourly stat records`);
|
|
||||||
|
|
||||||
// If no stat data, fall back to raw heartbeat data
|
// If no stat data, fall back to raw heartbeat data
|
||||||
if (stats.length === 0) {
|
if (stats.length === 0) {
|
||||||
console.log(`[HEARTBEAT-RANGE] No stat data found, falling back to raw heartbeat data`);
|
|
||||||
return null; // This will trigger fallback in router
|
return null; // This will trigger fallback in router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +64,6 @@ async function getAggregatedHeartbeatData(monitorId, range) {
|
||||||
ping: stat.ping
|
ping: stat.ping
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-RANGE] Returning ${result.length} stat records for client aggregation`);
|
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
// Use daily stats for ranges over 24 hours
|
// Use daily stats for ranges over 24 hours
|
||||||
|
@ -81,19 +71,14 @@ async function getAggregatedHeartbeatData(monitorId, range) {
|
||||||
const startTime = now.subtract(days, "days");
|
const startTime = now.subtract(days, "days");
|
||||||
const timestampKey = Math.floor(startTime.valueOf() / (24 * 60 * 60 * 1000)); // Convert to seconds
|
const timestampKey = Math.floor(startTime.valueOf() / (24 * 60 * 60 * 1000)); // Convert to seconds
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-RANGE] Using daily stats from timestamp ${timestampKey} (${dayjs(timestampKey * 1000).format()})`);
|
|
||||||
|
|
||||||
const stats = await R.getAll(`
|
const stats = await R.getAll(`
|
||||||
SELECT * FROM stat_daily
|
SELECT * FROM stat_daily
|
||||||
WHERE monitor_id = ? AND timestamp >= ?
|
WHERE monitor_id = ? AND timestamp >= ?
|
||||||
ORDER BY timestamp ASC
|
ORDER BY timestamp ASC
|
||||||
`, [monitorId, timestampKey]);
|
`, [monitorId, timestampKey]);
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-RANGE] Found ${stats.length} daily stat records`);
|
|
||||||
|
|
||||||
// If no stat data, fall back to raw heartbeat data
|
// If no stat data, fall back to raw heartbeat data
|
||||||
if (stats.length === 0) {
|
if (stats.length === 0) {
|
||||||
console.log(`[HEARTBEAT-RANGE] No stat data found, falling back to raw heartbeat data`);
|
|
||||||
return null; // This will trigger fallback in router
|
return null; // This will trigger fallback in router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +91,6 @@ async function getAggregatedHeartbeatData(monitorId, range) {
|
||||||
ping: stat.ping
|
ping: stat.ping
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-RANGE] Returning ${result.length} stat records for client aggregation`);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,16 +99,13 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
shortBeatList() {
|
shortBeatList() {
|
||||||
console.log(`[HEARTBEAT-BAR] shortBeatList called with range: ${this.heartbeatBarRange}, beatList: ${this.beatList ? this.beatList.length : 'null'} items`);
|
|
||||||
|
|
||||||
if (!this.beatList) {
|
if (!this.beatList) {
|
||||||
console.log(`[HEARTBEAT-BAR] No beatList - returning empty array`);
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If heartbeat range is configured (not auto), aggregate by time periods
|
// If heartbeat range is configured (not auto), aggregate by time periods
|
||||||
if (this.heartbeatBarRange && this.heartbeatBarRange !== "auto") {
|
if (this.heartbeatBarRange && this.heartbeatBarRange !== "auto") {
|
||||||
console.log(`[HEARTBEAT-BAR] Using aggregated beat list for range: ${this.heartbeatBarRange}`);
|
|
||||||
return this.aggregatedBeatList;
|
return this.aggregatedBeatList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,15 +130,12 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
aggregatedBeatList() {
|
aggregatedBeatList() {
|
||||||
console.log(`[HEARTBEAT-BAR] aggregatedBeatList called with range: ${this.heartbeatBarRange}, beatList length: ${this.beatList ? this.beatList.length : 'null'}, maxBeat: ${this.maxBeat}`);
|
|
||||||
|
|
||||||
if (!this.beatList || this.beatList.length === 0) {
|
if (!this.beatList || this.beatList.length === 0) {
|
||||||
console.log(`[HEARTBEAT-BAR] No beatList data`);
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always do client-side aggregation using dynamic maxBeat for proper screen sizing
|
// Always do client-side aggregation using dynamic maxBeat for proper screen sizing
|
||||||
console.log(`[HEARTBEAT-BAR] Performing client-side aggregation with ${this.maxBeat} buckets`);
|
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
const buckets = [];
|
const buckets = [];
|
||||||
|
|
||||||
|
@ -211,7 +205,6 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`[HEARTBEAT-BAR] Generated ${buckets.length} aggregated buckets using dynamic maxBeat`);
|
|
||||||
return buckets;
|
return buckets;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue