feat(qoder): show in Quota Tracker dashboard
Wire Qoder credits into the Quota Tracker card grid: - Add `qoder` to USAGE_SUPPORTED_PROVIDERS so the connection passes the isUsageEligible filter at /api/providers/client and shows up in providerOptions on the dashboard. - Reshape getQoderUsage so quota records (user, organization) live under `quotas` and scalar metadata (totalUsagePercentage, isQuotaExceeded, expiresAt) are siblings — the parser used to walk Object.entries(quotas) and would have rendered `totalUsagePercentage: 0.42` as a "0/0" row. - Surface Qoder's expiresAt as resetAt on each quota record so the card shows when credits reset. - Add a parser branch in ProviderLimits/utils.js: rename internal keys (user → "Personal", organization → "Organization"), drop empty org buckets so personal accounts don't render a misleading "0/0 Organization" row, and forward remaining/unit so the QuotaProgressBar can use them. - Add Qoder's brand color (#EC4899) to ProviderLimitCard's color map. 42 tests still pass; build clean.
This commit is contained in:
@@ -1175,26 +1175,40 @@ async function getQoderUsage(accessToken, proxyOptions = null) {
|
||||
if (!body) {
|
||||
return { message: "Qoder connected. Usage response was not JSON." };
|
||||
}
|
||||
// Quota records live under `quotas`; scalar metadata
|
||||
// (totalUsagePercentage, isQuotaExceeded, expiresAt) are surfaced as
|
||||
// siblings so the dashboard parser doesn't try to render them as rows.
|
||||
const userQuota = body.userQuota || {};
|
||||
const orgQuota = body.orgResourcePackage || {};
|
||||
// Qoder publishes a single absolute reset timestamp (`expiresAt` in ms);
|
||||
// surface it on every quota record as ISO so the table can render
|
||||
// "resets at" alongside used/total.
|
||||
const expiresAtMs = Number.isFinite(Number(body.expiresAt)) && Number(body.expiresAt) > 0
|
||||
? Number(body.expiresAt)
|
||||
: null;
|
||||
const resetAt = expiresAtMs ? new Date(expiresAtMs).toISOString() : null;
|
||||
const quotas = {
|
||||
user: {
|
||||
total: Number(userQuota.total) || 0,
|
||||
used: Number(userQuota.used) || 0,
|
||||
remaining: Number(userQuota.remaining) || 0,
|
||||
unit: userQuota.unit || "credits",
|
||||
resetAt,
|
||||
},
|
||||
organization: {
|
||||
total: Number(orgQuota.total) || 0,
|
||||
used: Number(orgQuota.used) || 0,
|
||||
remaining: Number(orgQuota.remaining) || 0,
|
||||
unit: orgQuota.unit || "credits",
|
||||
resetAt,
|
||||
},
|
||||
};
|
||||
return {
|
||||
quotas,
|
||||
totalUsagePercentage: Number(body.totalUsagePercentage) || 0,
|
||||
isQuotaExceeded: !!body.isQuotaExceeded,
|
||||
expiresAt: Number(body.expiresAt) || null,
|
||||
expiresAt: expiresAtMs,
|
||||
};
|
||||
return { quotas };
|
||||
} catch (error) {
|
||||
return { message: `Qoder connected. Unable to fetch usage: ${error.message}` };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user