GroupedChecks

This commit is contained in:
Alex Holliday committed 2026-01-05 04:17:11 +00:00
1 parent cdc58e5905
commit 3182141d0a
14 files changed
+592 -62

No files matched your search

@@ -33,6 +33,7 @@ export const XTick = ({ x, y, payload, range }: XTickProps) => {
const format = tickDateFormatLookup(range);
const theme = useTheme();
const uiTimezone = useAppSelector((state: any) => state.ui.timezone);
console.log(payload);
return (
<Text
x={x}
@@ -124,7 +125,7 @@ export const ChartResponseTime = ({
<XAxis
axisLine={false}
tickLine={false}
dataKey="_id"
dataKey="bucketDate"
tick={(props) => <XTick {...props} range={range} />}
/>
@@ -11,7 +11,7 @@ import { Fragment, useId } from "react";
import { XTick } from "./ChartResponseTime";
import { useTheme } from "@mui/material/styles";
import type { IInfraCheck } from "@/types/check";
import type { GroupedCheck } from "@/types/check";
const AREA_COLORS = [
// Blues
@@ -104,7 +104,7 @@ export const HistogramInfrastructure = ({
title: string;
type: string;
idx: number | null;
checks: IInfraCheck[];
checks: GroupedCheck[];
xKey: string;
yDomain?: number[];
dataKeys: string[];
@@ -118,15 +118,15 @@ export const HistogramInfrastructure = ({
const theme = useTheme();
const uniqueId = useId();
let avgTemps: { _id: string; avg_temp: number | null }[] = [];
let avgTemps: { bucketDate: Date; avg_temp: number | null }[] = [];
let tempYDomain: number[] = [];
if (type === "temp") {
avgTemps = checks.map((check) => {
const temps = check.cpu.temperature || [];
const temps = check.cpu?.temperature || [];
if (temps.length === 0) return { ...check, avg_temp: null };
const totalTemp = temps.reduce((sum, temp) => sum + (temp || 0), 0);
const avgTemp = totalTemp / temps.length;
return { _id: check._id, avg_temp: avgTemp };
return { bucketDate: check.bucketDate, avg_temp: avgTemp };
});
const maxTemp: number = avgTemps.reduce((max, item) => {
@@ -64,7 +64,7 @@ export const HistogramPageSpeedScores = ({
<ResponsiveContainer width="100%" minWidth={25} height={215}>
<AreaChart data={checks}>
<XAxis
dataKey={"_id"}
dataKey={"bucketDate"}
tick={(props) => <XTick {...props} range={range} />}
/>
<CartesianGrid
@@ -43,7 +43,7 @@ const XLabel = ({
fontSize={11}
fill={theme.palette.text.secondary}
>
{formatDateWithTz(p1._id, dateFormat, uiTimezone)}
{formatDateWithTz(p1.bucketDate, dateFormat, uiTimezone)}
</text>
<text
x="100%"
@@ -53,7 +53,7 @@ const XLabel = ({
fontSize={11}
fill={theme.palette.text.secondary}
>
{formatDateWithTz(p2._id, dateFormat, uiTimezone)}
{formatDateWithTz(p2.bucketDate, dateFormat, uiTimezone)}
</text>
</>
);
@@ -91,8 +91,8 @@ export const HistogramStatus = ({
const titleText = t("common.charts.uptime.avgResponseTime");
const fmt = range === "30d" ? "MMM D, YYYY" : "ddd, MMM D, YYYY, h:mm A";
let dateLabel = "";
if (d?._id) {
const base = new Date(d._id as any);
if (d?.bucketDate) {
const base = new Date(d.bucketDate);
const midBucket =
range === "30d" ? new Date(base.getTime() + 12 * 60 * 60 * 1000) : base;
dateLabel = formatDateWithTz(midBucket.toISOString(), fmt, uiTimezone);
@@ -174,7 +174,7 @@ export const HistogramStatus = ({
);
return (
<Cell
key={groupedCheck._id}
key={groupedCheck.bucketDate}
fill={theme.palette[fillColor].main}
/>
);