From 86bcb85e9bd6004609a5fc519fd26ac2af6fb88e Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Wed, 18 Jan 2023 16:38:55 +0000 Subject: [PATCH] Perform sanity check on uptime for status page Fixes #2628 A sanity check is performed when calculating the uptime of a monitor on status page. If it is greater than 100%, we just show 100%. This hasn't been implemented on the dashboard at the request of @louislam due to concerns it would make debugging more difficult in future if changes were made to the uptime calculation. Signed-off-by: Matthew Nickson --- src/components/Uptime.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Uptime.vue b/src/components/Uptime.vue index 7b5f48bb7..09a531a59 100644 --- a/src/components/Uptime.vue +++ b/src/components/Uptime.vue @@ -33,7 +33,13 @@ export default { let key = this.monitor.id + "_" + this.type; if (this.$root.uptimeList[key] !== undefined) { - return Math.round(this.$root.uptimeList[key] * 10000) / 100 + "%"; + let result = Math.round(this.$root.uptimeList[key] * 10000) / 100; + // Only perform sanity check on status page. See louislam/uptime-kuma#2628 + if (this.$route.path.startsWith("/status")) { + return result > 100 ? "100%" : result + "%"; + } else { + return result + "%"; + } } return this.$t("notAvailableShort");