From 94adf2c9d412f93ba5352a6781043ec117a2645b Mon Sep 17 00:00:00 2001 From: Doruk Date: Sat, 14 Jun 2025 12:37:45 +0200 Subject: [PATCH] cleaned up debugging --- server/routers/status-page-router.js | 6 ------ server/util/heartbeat-range.js | 16 ---------------- src/components/HeartbeatBar.vue | 7 ------- 3 files changed, 29 deletions(-) diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 2f9d05ad4..88f788bda 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -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 heartbeatRange = statusPage ? statusPage.heartbeat_bar_range : "auto"; - console.log(`[STATUS-PAGE] Processing ${monitorIDList.length} monitors with range: ${heartbeatRange}`); - for (let monitorID of monitorIDList) { let list; @@ -99,11 +97,9 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques if (aggregatedData) { // Use pre-aggregated stat data - console.log(`[STATUS-PAGE] Using aggregated data for monitor ${monitorID}: ${aggregatedData.length} records`); heartbeatList[monitorID] = aggregatedData; } else { // 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") { // 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); 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(` SELECT * FROM heartbeat @@ -136,7 +131,6 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques list = R.convertToBeans("heartbeat", list); 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); diff --git a/server/util/heartbeat-range.js b/server/util/heartbeat-range.js index ffc92016c..745d9d30c 100644 --- a/server/util/heartbeat-range.js +++ b/server/util/heartbeat-range.js @@ -32,35 +32,26 @@ function parseRangeHours(range) { * @returns {Promise} Aggregated heartbeat data */ async function getAggregatedHeartbeatData(monitorId, range) { - console.log(`[HEARTBEAT-RANGE] Getting aggregated data for monitor ${monitorId}, range: ${range}`); - if (!range || range === "auto") { - console.log(`[HEARTBEAT-RANGE] Auto mode - returning null to use regular heartbeat query`); return null; } const now = dayjs(); const hours = parseRangeHours(range); - console.log(`[HEARTBEAT-RANGE] Parsed ${range} to ${hours} hours`); if (hours <= 24) { // Use hourly stats for ranges up to 24 hours const startTime = now.subtract(hours, "hours"); 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(` SELECT * FROM stat_hourly WHERE monitor_id = ? AND timestamp >= ? ORDER BY timestamp ASC `, [monitorId, timestampKey]); - console.log(`[HEARTBEAT-RANGE] Found ${stats.length} hourly stat records`); - // If no stat data, fall back to raw heartbeat data 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 } @@ -73,7 +64,6 @@ async function getAggregatedHeartbeatData(monitorId, range) { ping: stat.ping })); - console.log(`[HEARTBEAT-RANGE] Returning ${result.length} stat records for client aggregation`); return result; } else { // Use daily stats for ranges over 24 hours @@ -81,19 +71,14 @@ async function getAggregatedHeartbeatData(monitorId, range) { const startTime = now.subtract(days, "days"); 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(` SELECT * FROM stat_daily WHERE monitor_id = ? AND timestamp >= ? ORDER BY timestamp ASC `, [monitorId, timestampKey]); - console.log(`[HEARTBEAT-RANGE] Found ${stats.length} daily stat records`); - // If no stat data, fall back to raw heartbeat data 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 } @@ -106,7 +91,6 @@ async function getAggregatedHeartbeatData(monitorId, range) { ping: stat.ping })); - console.log(`[HEARTBEAT-RANGE] Returning ${result.length} stat records for client aggregation`); return result; } } diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index c66f6181e..40cd34155 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -99,16 +99,13 @@ export default { }, shortBeatList() { - console.log(`[HEARTBEAT-BAR] shortBeatList called with range: ${this.heartbeatBarRange}, beatList: ${this.beatList ? this.beatList.length : 'null'} items`); if (!this.beatList) { - console.log(`[HEARTBEAT-BAR] No beatList - returning empty array`); return []; } // If heartbeat range is configured (not auto), aggregate by time periods if (this.heartbeatBarRange && this.heartbeatBarRange !== "auto") { - console.log(`[HEARTBEAT-BAR] Using aggregated beat list for range: ${this.heartbeatBarRange}`); return this.aggregatedBeatList; } @@ -133,15 +130,12 @@ export default { }, 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) { - console.log(`[HEARTBEAT-BAR] No beatList data`); return []; } // 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 buckets = []; @@ -211,7 +205,6 @@ export default { } }); - console.log(`[HEARTBEAT-BAR] Generated ${buckets.length} aggregated buckets using dynamic maxBeat`); return buckets; },