fix: aggregate ingestion throughput chart by time bucket

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.
This commit is contained in:
Celes Renata
2026-04-16 00:52:29 +00:00
parent 6eda988e3b
commit b5c0c6d7c9
+16 -9
View File
@@ -11,15 +11,22 @@ export function OpsIngestionPage() {
if (tpLoading) return <LoadingSpinner />;
const chartData = (throughput ?? []).map((row: unknown) => {
const r = row as Record<string, unknown>;
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<string, { time: string; completed: number; failed: number; items: number }>();
for (const row of throughput ?? []) {
const r = row as Record<string, unknown>;
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<string, unknown>;