diff --git a/src/output/quota-table.ts b/src/output/quota-table.ts index 0611318..839c58d 100644 --- a/src/output/quota-table.ts +++ b/src/output/quota-table.ts @@ -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, diff --git a/src/types/api.ts b/src/types/api.ts index ad59e02..4c81903 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -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; diff --git a/test/output/quota-table.test.ts b/test/output/quota-table.test.ts index 3c0a42c..69d6e2a 100644 --- a/test/output/quota-table.test.ts +++ b/test/output/quota-table.test.ts @@ -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, @@ -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'); + }); });