From 86bcb85e9bd6004609a5fc519fd26ac2af6fb88e Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Wed, 18 Jan 2023 16:38:55 +0000 Subject: [PATCH 1/2] 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"); From e9044ae95659f0fdf928e0cba0abef30835f808d Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Mon, 23 Jan 2023 18:10:45 +0000 Subject: [PATCH 2/2] Removed repetitiion of % Signed-off-by: Matthew Nickson --- src/components/Uptime.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Uptime.vue b/src/components/Uptime.vue index 09a531a59..afb82fa5e 100644 --- a/src/components/Uptime.vue +++ b/src/components/Uptime.vue @@ -35,8 +35,8 @@ export default { if (this.$root.uptimeList[key] !== undefined) { 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 + "%"; + if (this.$route.path.startsWith("/status") && result > 100) { + return "100%"; } else { return result + "%"; }