refactor uptime details query

This commit is contained in:
Alex Holliday committed 2025-01-10 12:12:33 -08:00
1 parent d495ca67e1
commit 12cc20a852
5 files changed
+61 -99

No files matched your search

+11 -13
View File
@@ -221,17 +221,17 @@ const DetailsPage = () => {
<StatBox
sx={statusStyles[determineState(monitor)]}
heading={"active for"}
subHeading={splitDuration(monitor?.stats?.timeSinceLastFalseCheck)}
subHeading={splitDuration(monitor?.uptimeStreak)}
/>
<StatBox
heading="last check"
subHeading={splitDuration(monitor?.stats?.timeSinceLastCheck)}
subHeading={splitDuration(monitor?.timeSinceLastCheck)}
/>
<StatBox
heading="last response time"
subHeading={
<>
{monitor?.stats?.latestResponseTime}
{monitor?.latestResponseTime}
<Typography component="span">{"ms"}</Typography>
</>
}
@@ -308,7 +308,7 @@ const DetailsPage = () => {
<Typography component="span">
{hoveredUptimeData !== null
? hoveredUptimeData.totalChecks
: (monitor.stats?.upChecks?.reduce((count, checkGroup) => {
: (monitor?.groupedUpChecks?.reduce((count, checkGroup) => {
return count + checkGroup.totalChecks;
}, 0) ?? 0)}
</Typography>
@@ -338,8 +338,8 @@ const DetailsPage = () => {
{hoveredUptimeData !== null
? Math.floor(hoveredUptimeData?.avgResponseTime ?? 0)
: Math.floor(
((monitor?.stats?.upChecksAggregate?.totalChecks ?? 0) /
(monitor?.stats?.totalChecks ?? 1)) *
((monitor?.upChecks?.totalChecks ?? 0) /
(monitor?.totalChecks ?? 1)) *
100
)}
<Typography component="span">
@@ -349,7 +349,7 @@ const DetailsPage = () => {
</Box>
</Stack>
<UpBarChart
stats={monitor?.stats}
monitor={monitor}
type={dateRange}
onBarHover={setHoveredUptimeData}
/>
@@ -366,7 +366,7 @@ const DetailsPage = () => {
<Typography component="span">
{hoveredIncidentsData !== null
? hoveredIncidentsData.totalChecks
: (monitor.stats?.downChecks?.reduce((count, checkGroup) => {
: (monitor?.groupedDownChecks?.reduce((count, checkGroup) => {
return count + checkGroup.totalChecks;
}, 0) ?? 0)}
</Typography>
@@ -388,7 +388,7 @@ const DetailsPage = () => {
)}
</Box>
<DownBarChart
stats={monitor?.stats}
monitor={monitor}
type={dateRange}
onBarHover={setHoveredIncidentsData}
/>
@@ -400,9 +400,7 @@ const DetailsPage = () => {
</IconBox>
<Typography component="h2">Average Response Time</Typography>
</Stack>
<ResponseGaugeChart
avgResponseTime={monitor?.stats?.groupAggregate?.avgResponseTime ?? 0}
/>
<ResponseGaugeChart avgResponseTime={monitor.avgResponseTime ?? 0} />
</ChartBox>
<ChartBox sx={{ padding: 0 }}>
<Stack
@@ -415,7 +413,7 @@ const DetailsPage = () => {
<Typography component="h2">Response Times</Typography>
</Stack>
<MonitorDetailsAreaChart
checks={monitor?.stats?.groupChecks ?? []}
checks={monitor.groupedChecks ?? []}
dateRange={dateRange}
/>
</ChartBox>