mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user