Skip to content

Commit 688c664

Browse files
committed
fix: promote abbreviateCount to next tier at boundaries, cap onPage at limit
- Promote to next tier when Math.round(scaled) reaches 1000 (e.g. 999950 → '1000K' was misleading, now correctly shows '1.0M') - Cap onPage reported count at options.limit so progress never shows '120/100' when the last page overshoots the requested limit
1 parent c5cdbee commit 688c664

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/lib/api-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ export async function listIssuesAllPages(
10971097
});
10981098

10991099
allResults.push(...response.data);
1100-
options.onPage?.(allResults.length, options.limit);
1100+
options.onPage?.(Math.min(allResults.length, options.limit), options.limit);
11011101

11021102
// Stop if we've reached the requested limit or there are no more pages
11031103
if (allResults.length >= options.limit || !response.nextCursor) {

src/lib/formatters/human.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,19 @@ function abbreviateCount(raw: string): string {
333333
const tier = Math.min(Math.floor(Math.log10(n) / 3), QUANTIFIERS.length - 1);
334334
const suffix = QUANTIFIERS[tier] ?? "";
335335
const scaled = n / 10 ** (tier * 3);
336-
// Only show decimal when it adds information — check the rounded value to avoid
336+
// Only show decimal when it adds information — compare the rounded value to avoid
337337
// "100.0K" when scaled is e.g. 99.95 (toFixed(1) rounds up to "100.0")
338338
const rounded1dp = Number(scaled.toFixed(1));
339-
const abbreviated =
340-
rounded1dp < 100
341-
? `${rounded1dp.toFixed(1)}${suffix}`
342-
: `${Math.round(scaled)}${suffix}`;
343-
return abbreviated.padStart(COL_COUNT);
339+
if (rounded1dp < 100) {
340+
return `${rounded1dp.toFixed(1)}${suffix}`.padStart(COL_COUNT);
341+
}
342+
const rounded = Math.round(scaled);
343+
// Promote to next tier if rounding produces >= 1000 (e.g. 999.95 → "1000K" → "1.0M")
344+
if (rounded >= 1000 && tier < QUANTIFIERS.length - 1) {
345+
const nextSuffix = QUANTIFIERS[tier + 1] ?? "";
346+
return `${(rounded / 1000).toFixed(1)}${nextSuffix}`.padStart(COL_COUNT);
347+
}
348+
return `${rounded}${suffix}`.padStart(COL_COUNT);
344349
}
345350

346351
/** Column where title starts in single-project mode (no ALIAS column) */

0 commit comments

Comments
 (0)