import { Card, CardContent, CardHeader, CardTitle, CardDescription, } from "@bullstudio/ui/components/card"; import { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, type ChartConfig, } from "@bullstudio/ui/components/chart"; import { Line, LineChart, XAxis, YAxis, CartesianGrid } from "recharts"; import dayjs from "@bullstudio/dayjs"; import type { OverviewMetricsResponse } from "@/integrations/trpc/routers/overview"; import { formatMs } from "@bullstudio/ui/shared"; type TimeSeriesDataPoint = OverviewMetricsResponse["timeSeries"][number]; type ProcessingTimeChartProps = { data: TimeSeriesDataPoint[]; timeRange: number; }; const chartConfig: ChartConfig = { processingTime: { label: "Processing Time", color: "hsl(217, 91%, 60%)", }, queueDelay: { label: "Queue Delay", color: "hsl(45, 93%, 47%)", }, }; export function ProcessingTimeChart({ data, timeRange, }: ProcessingTimeChartProps) { const formattedData = data.map((point) => ({ time: dayjs(point.timestamp).format(timeRange <= 24 ? "HH:mm" : "MMM D"), processingTime: Math.round(point.avgProcessingTimeMs), queueDelay: Math.round(point.avgDelayMs), })); return ( Processing Performance Average processing time and queue delay over the last {timeRange}h formatMs(value)} /> formatMs(value as number)} /> } /> } /> ); }