From 0de30dad10ecdfdc37e322cf214530ec828150c0 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 3 May 2026 07:04:34 +0000 Subject: [PATCH] fix(billing): skip realtime segment when bandwidth < realtimeBandwidth A handful of legacy orgs have realtime bandwidth tracked separately (not yet billed and not added into the bandwidth resource). For them realtimeBytes > totalBytes, which would otherwise overflow the bar or collapse the regular segment to zero. Detect that case and render bandwidth as a single segment instead, preserving today's behaviour for those orgs. --- .../billing/planSummary.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index 11e25948f..e611e8fe9 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -157,9 +157,12 @@ const maxBytes = maxGB * 1000 * 1000 * 1000; const percentage = Math.min((totalBytes / maxBytes) * 100, 100); - // Backend already rolls realtimeBytes into totalBytes; carve the realtime - // slice out of the total instead of summing them. Clamp in case of dirty data. - const realtimePortion = Math.max(0, Math.min(realtimeBytes, totalBytes)); + // Backend rolls realtimeBytes into totalBytes for billed orgs, so realtime + // is a slice of the total. A handful of legacy orgs still have realtime + // tracked separately (not billed yet) — for them realtime > total. In that + // case skip the breakdown and render the bandwidth as a single segment. + const showRealtimeSegment = realtimeBytes > 0 && realtimeBytes <= totalBytes; + const realtimePortion = showRealtimeSegment ? realtimeBytes : 0; const regularPortion = Math.max(0, totalBytes - realtimePortion); const regularSize = humanFileSize(regularPortion); const realtimeSize = humanFileSize(realtimePortion);