overview: normalize float-residue spend (e.g. -5.55e-17 after cycle reset) to 0 so the panel never renders -0.00

This commit is contained in:
inference-bot committed 2026-10-19 11:42:58 -06:00
1 parent fd13bc6ea2
commit 5425efee1f
1 file changed
+7 -1
+7 -1
View File
@@ -2471,7 +2471,13 @@ async def admin_overview(request: Request):
for email, active, balance, user_id in rows: for email, active, balance, user_id in rows:
team = teams.get(f"member:{email}", {}) team = teams.get(f"member:{email}", {})
spend = float(team.get("spend") or 0.0) spend = float(team.get("spend") or 0.0)
member_all_time = all_time_spend.get(f"member:{email}", 0.0) member_all_time = float(all_time_spend.get(f"member:{email}", 0.0))
# Normalize floating-point residue (e.g. -5.55e-17 after a cycle reset)
# so the panel/dashboards never render "-0.00".
if abs(spend) < 1e-9:
spend = 0.0
if abs(member_all_time) < 1e-9:
member_all_time = 0.0
credits = get_credit_balance(email) credits = get_credit_balance(email)
eff = compute_max_budget( eff = compute_max_budget(
float(balance) if balance is not None else MEMBER_BUDGET, float(balance) if balance is not None else MEMBER_BUDGET,