From ee53ded19e580f379cf60ca0a6187d6bb8615bb4 Mon Sep 17 00:00:00 2001 From: Stephen Papierski Date: Wed, 15 Nov 2023 15:38:10 -0700 Subject: [PATCH] Simplify logic due to bug fix --- server/model/heartbeat.js | 3 +++ src/components/PingChart.vue | 7 ++----- src/mixins/socket.js | 28 ++-------------------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/server/model/heartbeat.js b/server/model/heartbeat.js index 0084f49a3..f18bbf17e 100644 --- a/server/model/heartbeat.js +++ b/server/model/heartbeat.js @@ -6,6 +6,9 @@ const { BeanModel } = require("redbean-node/dist/bean-model"); * 1 = UP * 2 = PENDING * 3 = MAINTENANCE + * pingStatus: + * 3 = SLOW + * 4 = NOMINAL */ class Heartbeat extends BeanModel { diff --git a/src/components/PingChart.vue b/src/components/PingChart.vue index b34629ccc..b667dc96a 100644 --- a/src/components/PingChart.vue +++ b/src/components/PingChart.vue @@ -63,12 +63,9 @@ export default { []; let lastBeat = heartbeatList.at(-1); - // TODO: Simplify? When page loads, lastBeat contains ping_threshold, - // but after the following heartbeat it has pingThreshold. - if (lastBeat?.hasOwnProperty("pingThreshold")) { + + if (lastBeat) { return lastBeat.pingThreshold; - } else if (lastBeat?.hasOwnProperty("ping_threshold")) { - return lastBeat.ping_threshold; } else { return undefined; } diff --git a/src/mixins/socket.js b/src/mixins/socket.js index 8ded9283e..0c20d41ad 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -763,28 +763,12 @@ export default { let lastHeartBeat = this.lastHeartbeatList[monitorID]; if (lastHeartBeat?.status === UP) { - // TODO ping_status(1st) vs pingStatus(every other time) - let pingStatus; - if (lastHeartBeat.hasOwnProperty("ping_status")) { - pingStatus = lastHeartBeat.ping_status; - } else if (lastHeartBeat.hasOwnProperty("pingStatus")) { - pingStatus = lastHeartBeat.pingStatus; - } - - if (pingStatus === SLOW) { + if (lastHeartBeat.pingStatus === SLOW) { result[monitorID] = { text: this.$t("Slow"), color: "warning", }; } - // TODO Decide: currently only shows if "slow". Add the - // code below else if we want to display "nominal" as well - // else if (pingStatus === NOMINAL) { - // result[monitorID] = { - // text: this.$t("Nominal"), - // color: "primary", - // }; - // } } } return result; @@ -822,15 +806,7 @@ export default { result.unknown++; } - // TODO ping_status(1st) vs pingStatus(every other time) - let pingStatus; - if (beat.hasOwnProperty("ping_status")) { - pingStatus = beat.ping_status; - } else if (beat.hasOwnProperty("pingStatus")) { - pingStatus = beat.pingStatus; - } - - if (pingStatus === SLOW) { + if (beat.pingStatus === SLOW) { result.slow++; } } else {