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
* 2 = PENDING
* 3 = MAINTENANCE
* pingStatus:
* 3 = SLOW
* 4 = NOMINAL
*/
class Heartbeat extends BeanModel {

View file

@ -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;
}

View file

@ -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 {