diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 29acaf8e..d54525d8 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -80,20 +80,32 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques ]); for (let monitorID of monitorIDList) { + // Calculating the percentage of uptime per day with the status count to show full year data let list = await R.getAll(` - SELECT * FROM heartbeat + SELECT + strftime('%Y-%m-%d', time) AS day, + (COUNT(CASE WHEN status = 1 THEN 1 END) * 100.0) / COUNT(status) AS percentage, + ( + SELECT status + FROM heartbeat AS sub + WHERE strftime('%Y-%m-%d', sub.time) = strftime('%Y-%m-%d', main.time) + GROUP BY status + ORDER BY COUNT(*) DESC + LIMIT 1 + ) as status + FROM heartbeat as main WHERE monitor_id = ? - ORDER BY time DESC - LIMIT 50 + GROUP BY day + ORDER BY day DESC + LIMIT 365 `, [ monitorID, ]); - list = R.convertToBeans("heartbeat", list); - heartbeatList[monitorID] = list.reverse().map(row => row.toPublicJSON()); + heartbeatList[monitorID] = list; const uptimeCalculator = await UptimeCalculator.getUptimeCalculator(monitorID); - uptimeList[`${monitorID}_24`] = uptimeCalculator.get24Hour().uptime; + uptimeList[`${monitorID}_1y`] = uptimeCalculator.get1Year().uptime; } response.json({ diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index f1631440..324641cd 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -1,17 +1,30 @@ - diff --git a/src/components/HeartbeatBarStatus.vue b/src/components/HeartbeatBarStatus.vue new file mode 100644 index 00000000..7c76392e --- /dev/null +++ b/src/components/HeartbeatBarStatus.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index 2d17871f..5920f907 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -38,7 +38,7 @@ - + {{ monitor.element.name }} -

{{ monitor.element.name }}

+

{{ monitor.element.name }}

- - +
@@ -88,7 +87,7 @@