Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/commands/quota/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export default defineCommand({

if (config.quiet) {
for (const m of models) {
const remaining = m.current_interval_total_count - m.current_interval_usage_count;
console.log(`${m.model_name}\t${m.current_interval_usage_count}\t${m.current_interval_total_count}\t${remaining}`);
// NOTE: current_interval_usage_count is misleadingly named by the API —
// it represents REMAINING count, not used. See issue #70.
const remaining = m.current_interval_usage_count;
const used = Math.max(0, m.current_interval_total_count - remaining);
console.log(`${m.model_name}\t${used}\t${m.current_interval_total_count}\t${remaining}`);
}
return;
}
Expand Down
3 changes: 3 additions & 0 deletions src/output/quota-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ export function renderQuotaTable(models: QuotaModelRemain[], config: Config): vo
for (const m of models) {
console.log(boxLine(W, '├', '─', '┤', useColor));

// NOTE: current_interval_usage_count is misleadingly named by the API —
// it represents REMAINING count, not used. See issue #70.
const remaining = m.current_interval_usage_count;
const limit = m.current_interval_total_count;
const used = Math.max(0, limit - remaining);
const usedPct = limit > 0 ? Math.round((used / limit) * 100) : 0;
// Same misleading naming for weekly.
const weekRemaining = m.current_weekly_usage_count;
const weekLimit = m.current_weekly_total_count;
const weekUsed = Math.max(0, weekLimit - weekRemaining);
Expand Down
2 changes: 2 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ export interface QuotaModelRemain {
end_time: number;
remains_time: number;
current_interval_total_count: number;
/** @deprecated Misleading API naming: this represents REMAINING count, not usage. */
current_interval_usage_count: number;
current_weekly_total_count: number;
/** @deprecated Misleading API naming: this represents REMAINING count, not usage. */
current_weekly_usage_count: number;
weekly_start_time: number;
weekly_end_time: number;
Expand Down
Loading