mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
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:
@@ -165,6 +165,10 @@ export function parseQuotaData(provider, data) {
|
|||||||
// quota, both with same shape: {total, used, remaining, unit, resetAt}.
|
// quota, both with same shape: {total, used, remaining, unit, resetAt}.
|
||||||
// Skip an organization bucket when its total is 0 — most personal
|
// Skip an organization bucket when its total is 0 — most personal
|
||||||
// Qoder accounts won't have one and rendering "0/0" is misleading.
|
// 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) {
|
if (data.quotas) {
|
||||||
Object.entries(data.quotas).forEach(([quotaType, quota]) => {
|
Object.entries(data.quotas).forEach(([quotaType, quota]) => {
|
||||||
if (quotaType === "organization" && (!quota || (Number(quota.total) || 0) === 0)) {
|
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,
|
name: quotaType === "user" ? "Personal" : quotaType === "organization" ? "Organization" : quotaType,
|
||||||
used: quota.used || 0,
|
used: quota.used || 0,
|
||||||
total: quota.total || 0,
|
total: quota.total || 0,
|
||||||
remaining: quota.remaining,
|
|
||||||
unit: quota.unit,
|
unit: quota.unit,
|
||||||
resetAt: quota.resetAt || null,
|
resetAt: quota.resetAt || null,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user