Refactored to deal with empty data set

This commit is contained in:
Alex Holliday committed 2024-06-24 10:59:18 -07:00
1 parent 68cb5b4597
commit d883898384
3 files changed
+30 -15

No files matched your search

+4 -2
View File
@@ -12,15 +12,17 @@ import PropTypes from "prop-types";
const CurrentStats = ({ monitors }) => {
const up = monitors.reduce((acc, cur) => {
if (cur.checks) {
if (cur.checks.length > 0) {
return cur.checks[cur.checks.length - 1].status === true ? acc + 1 : acc;
}
return 0;
}, 0);
const down = monitors.reduce((acc, cur) => {
if (cur.checks) {
if (cur.checks.length > 0) {
return cur.checks[cur.checks.length - 1].status === false ? acc + 1 : acc;
}
return 0;
}, 0);
return (