correctly calculate grouped uptime percentage
This commit is contained in:
1 parent
0c96ffe3d0
commit
e2170981e4
2 files changed
+11
-6
No files matched your search
@@ -30,6 +30,12 @@ const ChartBoxes = ({
|
|||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const totalUpChecks = monitor?.upChecks?.totalChecks ?? 0;
|
||||||
|
const totalDownChecks = monitor?.downChecks?.totalChecks ?? 0;
|
||||||
|
const denominator =
|
||||||
|
totalUpChecks + totalDownChecks > 0 ? totalUpChecks + totalDownChecks : 1;
|
||||||
|
const groupedUptimePercentage = (totalUpChecks / denominator) * 100;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -73,11 +79,7 @@ const ChartBoxes = ({
|
|||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null
|
{hoveredUptimeData !== null
|
||||||
? Math.floor(hoveredUptimeData?.avgResponseTime ?? 0)
|
? Math.floor(hoveredUptimeData?.avgResponseTime ?? 0)
|
||||||
: Math.floor(
|
: Math.floor(groupedUptimePercentage)}
|
||||||
((monitor?.upChecks?.totalChecks ?? 0) /
|
|
||||||
(monitor?.totalChecks ?? 1)) *
|
|
||||||
100
|
|
||||||
)}
|
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null ? " ms" : " %"}
|
{hoveredUptimeData !== null ? " ms" : " %"}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -372,7 +372,10 @@ const getUptimeDetailsById = async (req) => {
|
|||||||
|
|
||||||
const getDistributedUptimeDetailsById = async (req) => {
|
const getDistributedUptimeDetailsById = async (req) => {
|
||||||
try {
|
try {
|
||||||
const { monitorId } = req.params;
|
const { monitorId } = req?.params ?? {};
|
||||||
|
if (typeof monitorId === "undefined") {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
const monitor = await Monitor.findById(monitorId);
|
const monitor = await Monitor.findById(monitorId);
|
||||||
if (monitor === null || monitor === undefined) {
|
if (monitor === null || monitor === undefined) {
|
||||||
throw new Error(this.stringService.dbFindMonitorById(monitorId));
|
throw new Error(this.stringService.dbFindMonitorById(monitorId));
|
||||||
|
|||||||
Reference in new issue
Block a user