fix: percentage calc

This commit is contained in:
Mats Stottmeister 2025-06-10 23:13:03 +02:00
parent 7deafe425c
commit f256efdcd1
No known key found for this signature in database

View file

@ -190,11 +190,11 @@ router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (
date: row.date, date: row.date,
// Additional daily stats // Additional daily stats
dailyStats: { dailyStats: {
total: row.total_beats, total: parseInt(row.total_beats) || 0,
up: row.up_beats, up: parseInt(row.up_beats) || 0,
down: row.down_beats, down: parseInt(row.down_beats) || 0,
pending: row.pending_beats, pending: parseInt(row.pending_beats) || 0,
maintenance: row.maintenance_beats maintenance: parseInt(row.maintenance_beats) || 0
} }
}; };
}); });
@ -211,8 +211,9 @@ router.get("/api/status-page/heartbeat-daily/:slug", cache("5 minutes"), async (
recentData.forEach(day => { recentData.forEach(day => {
if (day.dailyStats) { if (day.dailyStats) {
totalUp += day.dailyStats.up; // Convert strings to numbers to avoid concatenation
totalDown += day.dailyStats.down; totalUp += parseInt(day.dailyStats.up) || 0;
totalDown += parseInt(day.dailyStats.down) || 0;
} }
}); });