fix(qoder): drop remaining from normalized quota — was rendering as %

Qoder's API returns `remaining` as an absolute credit count (e.g. 348
out of 3000), but ProviderLimits' getRemainingPercentage and QuotaTable
treat the `remaining` field as a 0-100 percentage. Result: "348%" with
red status.

Stop forwarding `remaining` from the qoder parser. The percentage is
computed from used/total via calculatePercentage, which gives the
correct ~12% remaining for the example case.
This commit is contained in:
Simon Shi
2026-05-23 23:42:05 +09:00
committed by decolua
parent af7f6b1de2
commit 3d523b1387

View File

@@ -165,6 +165,10 @@ export function parseQuotaData(provider, data) {
// quota, both with same shape: {total, used, remaining, unit, resetAt}.
// Skip an organization bucket when its total is 0 — most personal
// Qoder accounts won't have one and rendering "0/0" is misleading.
// Don't forward Qoder's `remaining` field: it's an absolute credit
// count, but getRemainingPercentage / QuotaTable interpret
// `remaining` as a 0-100 percentage and would render 348 credits
// as "348%". The percentage is computed from used/total instead.
if (data.quotas) {
Object.entries(data.quotas).forEach(([quotaType, quota]) => {
if (quotaType === "organization" && (!quota || (Number(quota.total) || 0) === 0)) {
@@ -174,7 +178,6 @@ export function parseQuotaData(provider, data) {
name: quotaType === "user" ? "Personal" : quotaType === "organization" ? "Organization" : quotaType,
used: quota.used || 0,
total: quota.total || 0,
remaining: quota.remaining,
unit: quota.unit,
resetAt: quota.resetAt || null,
});