Skip to content
Open
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
5 changes: 4 additions & 1 deletion src/output/quota-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export function renderQuotaTable(models: QuotaModelRemain[], config: Config): vo
const L = config.region === 'cn' ? LABELS_CN : LABELS_EN;

const rows = models.map((m) => {
const displayName = displayModelName(m.model_name, config.region);
const baseName = displayModelName(m.model_name, config.region);
const boost = m.interval_boost_permille;
const boostTag = (boost && boost > 1000) ? ` ×${boost / 1000}` : '';
const displayName = baseName + boostTag;
const current = renderMetric(
L.current,
m.current_interval_usage_count,
Expand Down
4 changes: 4 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,13 @@ export interface QuotaModelRemain {
current_interval_total_count: number;
current_interval_usage_count: number;
current_interval_remaining_percent?: number;
current_interval_status?: number;
current_weekly_total_count: number;
current_weekly_usage_count: number;
current_weekly_remaining_percent?: number;
current_weekly_status?: number;
interval_boost_permille?: number;
weekly_boost_permille?: number;
weekly_start_time: number;
weekly_end_time: number;
weekly_remains_time: number;
Expand Down
71 changes: 71 additions & 0 deletions test/output/quota-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ function createCodingPlanModels(): QuotaModelRemain[] {
current_interval_total_count: 0,
current_interval_usage_count: 0,
current_interval_remaining_percent: 94,
current_interval_status: 1,
current_weekly_total_count: 0,
current_weekly_usage_count: 0,
current_weekly_remaining_percent: 98,
current_weekly_status: 1,
interval_boost_permille: 2000,
weekly_boost_permille: 2000,
weekly_start_time: Date.UTC(2026, 4, 31, 0, 0, 0),
weekly_end_time: Date.UTC(2026, 5, 7, 0, 0, 0),
weekly_remains_time: 6 * 24 * 60 * 60 * 1000,
Expand Down Expand Up @@ -129,4 +133,71 @@ describe('renderQuotaTable', () => {
expect(output).toContain('21 / 21');
expect(output).not.toContain('0 / 3');
});

it('renders boost multiplier when boost_permille > 1000', () => {
const lines: string[] = [];
const originalLog = console.log;

console.log = (message?: unknown) => {
lines.push(String(message ?? ''));
};

try {
renderQuotaTable(createCodingPlanModels(), {
...createConfig(),
region: 'cn',
noColor: true,
});
} finally {
console.log = originalLog;
}

const output = lines.join('\n');

// general model has interval_boost_permille=2000 => ×2 prefix
expect(output).toContain('通用 ×2');
// video model has no boost field => no ×2 on its row
// ensure the video line is still present (so the negative check is meaningful)
expect(output).toContain('视频');
});

it('omits boost multiplier when boost_permille is missing', () => {
const modelsNoBoost: QuotaModelRemain[] = [{
model_name: 'general',
start_time: Date.UTC(2026, 4, 31, 0, 0, 0),
end_time: Date.UTC(2026, 4, 31, 2, 0, 0),
remains_time: 2 * 60 * 60 * 1000,
current_interval_total_count: 100,
current_interval_usage_count: 50,
current_interval_remaining_percent: 50,
current_weekly_total_count: 1000,
current_weekly_usage_count: 200,
current_weekly_remaining_percent: 80,
weekly_start_time: Date.UTC(2026, 4, 31, 0, 0, 0),
weekly_end_time: Date.UTC(2026, 5, 7, 0, 0, 0),
weekly_remains_time: 6 * 24 * 60 * 60 * 1000,
}];

const lines: string[] = [];
const originalLog = console.log;

console.log = (message?: unknown) => {
lines.push(String(message ?? ''));
};

try {
renderQuotaTable(modelsNoBoost, {
...createConfig(),
region: 'cn',
noColor: true,
});
} finally {
console.log = originalLog;
}

const output = lines.join('\n');

expect(output).toContain('通用');
expect(output).not.toContain('×2');
});
});
Loading