Skip to content

Commit

Permalink
feat: highlight bad indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Apr 19, 2024
1 parent eaa3b33 commit 7a03157
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions frappe/desk/doctype/system_health_report/system_health_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,50 @@ frappe.ui.form.on("System Health Report", {
});
frappe.realtime.emit("ping");
frm.disable_save();
frm.trigger("setup_highlight");
},

setup_highlight(frm) {
/// field => is bad?
const conditions = {
scheduler_status: (val) => val.toLowerCase() != "active",
background_jobs_check: (val) => val.toLowerCase() != "finished",
total_background_workers: (val) => val == 0,
binary_logging: (val) => val.toLowerCase() != "on",
socketio_ping_check: (val) => val != "pass",
socketio_transport_mode: (val) => val != "websocket",
onsite_backups: (val) => val == 0,
failed_logins: (val) => val > frm.doc.total_users,
total_errors: (val) => val > 100,
// 5% excluding very small numbers
unhandled_emails: (val) =>
val > 3 && frm.doc.handled_emails > 3 && val / frm.doc.handled_emails > 0.05,
failed_emails: (val) =>
val > 3 &&
frm.doc.total_outgoing_emails > 3 &&
val / frm.doc.total_outgoing_emails > 0.05,
pending_emails: (val) =>
val > 3 &&
frm.doc.total_outgoing_emails > 3 &&
val / frm.doc.total_outgoing_emails > 0.1,
};

const update_fields = () => {
Object.entries(conditions).forEach(([field, condition]) => {
try {
let is_bad = condition(frm.doc[field]);
if (is_bad) {
// highlight
} else {
// remove highlight
}
} catch (e) {
console.log("Failed to evaluated", e);
}
});
};

update_fields();
const interval = setInterval(update_fields, 1000);
},
});

0 comments on commit 7a03157

Please sign in to comment.