incidents repo and data reversal

This commit is contained in:
Alex Holliday committed 2026-01-06 20:49:06 +00:00
1 parent 605b4713af
commit 51081a6a0e
32 files changed
+537 -241

No files matched your search

@@ -8,7 +8,7 @@ import { StatusLabel, ValueLabel } from "@/components/design-elements";
import { BaseBox } from "@/components/design-elements";
import { useAppSelector } from "@/hooks/AppHooks";
import type { ICheck } from "@/types/check";
import type { Check } from "@/types/check";
import type { MonitorStatus } from "@/types/monitor";
import { formatDateWithTz } from "@/utils/TimeUtils";
import { useTheme } from "@mui/material/styles";
@@ -16,7 +16,7 @@ import { getMonitorPath } from "@/utils/MonitorUtils";
import { useTranslation } from "react-i18next";
type CheckDetailsCardProps = {
check: ICheck;
check: Check;
};
export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
@@ -50,7 +50,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
const httpText = Number.isFinite(httpStatusCode)
? String(httpStatusCode)
: "-";
const typeText = check?.metadata?.type ?? "-";
const typeText = check?.type ?? "-";
const checkedAtText = check?.createdAt
? formatDateWithTz(check.createdAt, "ddd, MMM D, YYYY, HH:mm A", uiTimezone)
: "-";
@@ -71,7 +71,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
})}
</Typography>
{(() => {
const href = `/${getMonitorPath(check.metadata.type)}/${check.metadata.monitorId}`;
const href = `/${getMonitorPath(check.type)}/${check.monitorId}`;
return href ? (
<Typography variant="body2" sx={{ mt: 0.5 }}>
<Link
+2 -2
View File
@@ -1,4 +1,4 @@
import type { ICheck, CheckTimingPhases } from "@/types/check";
import type { Check, CheckTimingPhases } from "@/types/check";
import { PieChart, Pie, ResponsiveContainer, Tooltip, Legend } from "recharts";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
@@ -6,7 +6,7 @@ import { alpha, useTheme } from "@mui/material/styles";
import { useState } from "react";
import { BaseBox } from "@/components/design-elements";
import { useTranslation } from "react-i18next";
type TimingsChartProps = { check: ICheck | null };
type TimingsChartProps = { check: Check | null };
export type TimingSegment = {
name: string;
@@ -24,18 +24,17 @@ export const HeatmapResponseTime = ({
}
if (!checks || checks.length === 0) return null;
let data = Array<any>();
if (!checks || checks.length === 0) {
checks = [];
}
if (checks.length !== 25) {
const placeholders = Array(25 - checks.length).fill({
status: "placeholder",
const latestChecks = checks.slice(-25).reverse();
let data: Array<ICheck | { status: "placeholder" }>;
if (latestChecks.length !== 25) {
const placeholders = Array(25 - latestChecks.length).fill({
status: "placeholder" as const,
});
data = [...checks, ...placeholders];
data = [...latestChecks, ...placeholders];
} else {
data = checks;
data = latestChecks;
}
return (
<Box sx={{ width: "100%" }}>
@@ -3,15 +3,17 @@ import Tooltip from "@mui/material/Tooltip";
import Typography from "@mui/material/Typography";
import { formatDateWithTz } from "@/utils/TimeUtils";
import { useAppSelector } from "@/hooks/AppHooks";
import type { LatestCheck } from "@/types/check";
import type { Check } from "@/types/check";
import { useTheme } from "@mui/material/styles";
type HeatmapCheck = Check | { status: "placeholder" };
export const HeatmapResponseTimeTooltip = ({
children,
check,
}: {
children: React.ReactElement;
check: LatestCheck;
check: HeatmapCheck;
}) => {
const uiTimezone = useAppSelector((state: any) => state.ui.timezone);
const theme = useTheme();
@@ -47,7 +49,7 @@ export const HeatmapResponseTimeTooltip = ({
>
<Typography>
{formatDateWithTz(
check?.checkedAt,
check?.createdAt,
"ddd, MMMM D, YYYY, HH:mm A",
uiTimezone
)}
@@ -22,7 +22,10 @@ export const HistogramResponseTime = ({
if (!Array.isArray(checks) || checks.length === 0) return null;
const normalized = normalizeResponseTimes(checks.slice(-25), "responseTime");
const normalized = normalizeResponseTimes(
checks.slice(-25).reverse(),
"responseTime"
);
let data = Array<any>();
if (!normalized || normalized.length === 0) {
@@ -36,7 +39,6 @@ export const HistogramResponseTime = ({
} else {
data = normalized;
}
const chartHeight = typeof height === "number" ? `${height}px` : height;
const gridGap = gap ?? theme.spacing(0.5);
@@ -66,7 +66,7 @@ export const BarDockerCount = ({
) : (
<ResponsiveContainer width="100%" height={200}>
<BarChart
data={data}
data={[...data].reverse()}
margin={{ top: 8, right: 8, left: isSmall ? 4 : 12, bottom: 8 }}
>
<defs>
@@ -62,7 +62,7 @@ export const HistogramDockerPercentage = ({
) : (
<ResponsiveContainer width="100%" height={200}>
<AreaChart
data={data}
data={[...data].reverse()}
margin={{ top: 8, right: 8, left: isSmall ? 0 : 8, bottom: 8 }}
>
<CartesianGrid
@@ -117,11 +117,12 @@ export const HistogramInfrastructure = ({
}) => {
const theme = useTheme();
const uniqueId = useId();
let data = checks.reverse();
let avgTemps: { bucketDate: string; avg_temp: number | null }[] = [];
let tempYDomain: number[] = [];
if (type === "temp") {
avgTemps = checks.map((check) => {
avgTemps = data.map((check) => {
const temps = check.cpu?.temperature || [];
if (temps.length === 0) return { ...check, avg_temp: null };
const totalTemp = temps.reduce((sum, temp) => sum + (temp || 0), 0);
@@ -139,7 +140,7 @@ export const HistogramInfrastructure = ({
return (
<BaseChart icon={null} title={title}>
<ResponsiveContainer width="100%" height={200}>
<AreaChart data={type === "temp" ? avgTemps : checks}>
<AreaChart data={type === "temp" ? avgTemps : data}>
<XAxis
dataKey={xKey}
tick={(props) => <XTick {...props} range={range} />}