Simplify logic due to bug fix

This commit is contained in:
Stephen Papierski 2023-11-15 15:38:10 -07:00
parent 20d5ded721
commit ee53ded19e
No known key found for this signature in database
3 changed files with 7 additions and 31 deletions

View file

@ -6,6 +6,9 @@ const { BeanModel } = require("redbean-node/dist/bean-model");
* 1 = UP * 1 = UP
* 2 = PENDING * 2 = PENDING
* 3 = MAINTENANCE * 3 = MAINTENANCE
* pingStatus:
* 3 = SLOW
* 4 = NOMINAL
*/ */
class Heartbeat extends BeanModel { class Heartbeat extends BeanModel {

View file

@ -63,12 +63,9 @@ export default {
[]; [];
let lastBeat = heartbeatList.at(-1); let lastBeat = heartbeatList.at(-1);
// TODO: Simplify? When page loads, lastBeat contains ping_threshold,
// but after the following heartbeat it has pingThreshold. if (lastBeat) {
if (lastBeat?.hasOwnProperty("pingThreshold")) {
return lastBeat.pingThreshold; return lastBeat.pingThreshold;
} else if (lastBeat?.hasOwnProperty("ping_threshold")) {
return lastBeat.ping_threshold;
} else { } else {
return undefined; return undefined;
} }

View file

@ -763,28 +763,12 @@ export default {
let lastHeartBeat = this.lastHeartbeatList[monitorID]; let lastHeartBeat = this.lastHeartbeatList[monitorID];
if (lastHeartBeat?.status === UP) { if (lastHeartBeat?.status === UP) {
// TODO ping_status(1st) vs pingStatus(every other time) if (lastHeartBeat.pingStatus === SLOW) {
let pingStatus;
if (lastHeartBeat.hasOwnProperty("ping_status")) {
pingStatus = lastHeartBeat.ping_status;
} else if (lastHeartBeat.hasOwnProperty("pingStatus")) {
pingStatus = lastHeartBeat.pingStatus;
}
if (pingStatus === SLOW) {
result[monitorID] = { result[monitorID] = {
text: this.$t("Slow"), text: this.$t("Slow"),
color: "warning", 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; return result;
@ -822,15 +806,7 @@ export default {
result.unknown++; result.unknown++;
} }
// TODO ping_status(1st) vs pingStatus(every other time) if (beat.pingStatus === SLOW) {
let pingStatus;
if (beat.hasOwnProperty("ping_status")) {
pingStatus = beat.ping_status;
} else if (beat.hasOwnProperty("pingStatus")) {
pingStatus = beat.pingStatus;
}
if (pingStatus === SLOW) {
result.slow++; result.slow++;
} }
} else { } else {