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.
This commit is contained in:
michelia
2026-06-30 14:11:39 +08:00
committed by jialin
parent 457d2f2f72
commit 7d94c77c15
+6 -1
View File
@@ -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));