From 7d94c77c155adfe66fe7db30de70fd450a902e16 Mon Sep 17 00:00:00 2001 From: michelia Date: Tue, 30 Jun 2026 11:18:39 +0800 Subject: [PATCH] fix(usage): sum same-label buckets in the trend series buildTrendSeries overwrote a (label, bucket) value on collision. Should two backend groups ever map to the same display label, their values must add up rather than letting the last write win. Accumulate instead. --- src/pages/usage/utils/trend-series.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/usage/utils/trend-series.ts b/src/pages/usage/utils/trend-series.ts index b87e0bea..085d97c6 100644 --- a/src/pages/usage/utils/trend-series.ts +++ b/src/pages/usage/utils/trend-series.ts @@ -53,7 +53,12 @@ export const buildTrendSeries = (opts: { byGroup.set(label, new Map()); order.push(label); } - byGroup.get(label)!.set(bucketKey(i.date, granularity), valueOf(i, metric)); + // Sum rather than overwrite: should two backend groups ever map to the same + // display label, several rows can share a (label, bucket), so accumulate + // instead of letting the last write win. + const bucket = byGroup.get(label)!; + const key = bucketKey(i.date, granularity); + bucket.set(key, (bucket.get(key) ?? 0) + valueOf(i, metric)); }); const colors = palette(Math.max(order.length, 1));