From b5c0c6d7c9ab344cdc3ff366e660f4e708fd0419 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Thu, 16 Apr 2026 00:52:29 +0000 Subject: [PATCH] fix: aggregate ingestion throughput chart by time bucket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The throughput API returns one row per source_type per time bucket, but the chart was mapping each row as a separate bar. With 5 source types × 24 hours, the bars were tiny and overlapping. Now aggregates completed/failed/items across source types per time bucket so the chart shows meaningful totals. --- frontend/src/pages/OpsIngestion.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/OpsIngestion.tsx b/frontend/src/pages/OpsIngestion.tsx index b32e6fc..002ef2d 100644 --- a/frontend/src/pages/OpsIngestion.tsx +++ b/frontend/src/pages/OpsIngestion.tsx @@ -11,15 +11,22 @@ export function OpsIngestionPage() { if (tpLoading) return ; - const chartData = (throughput ?? []).map((row: unknown) => { - const r = row as Record; - return { - time: r.bucket_start ? new Date(r.bucket_start as string).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : '', - completed: Number(r.completed ?? 0), - failed: Number(r.failed ?? 0), - items: Number(r.items_fetched ?? 0), - }; - }); + const chartData = (() => { + const buckets = new Map(); + for (const row of throughput ?? []) { + const r = row as Record; + const time = r.bucket_start + ? new Date(r.bucket_start as string).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) + : ''; + if (!time) continue; + const existing = buckets.get(time) ?? { time, completed: 0, failed: 0, items: 0 }; + existing.completed += Number(r.completed ?? 0); + existing.failed += Number(r.failed ?? 0); + existing.items += Number(r.items_fetched ?? 0); + buckets.set(time, existing); + } + return Array.from(buckets.values()); + })(); const s = (summary ?? {}) as Record;