Skip to content
Merged
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
12 changes: 9 additions & 3 deletions apps/web-roo-code/src/lib/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@ export async function getVSCodeDownloads() {
}

function formatNumber(num: number): string {
// divide by 1000 to convert to "thousands" format,
// multiply by 10, floor the result, then divide by 10 to keep one decimal place.
// if number is 1 million or more, format as millions
if (num >= 1000000) {
const truncated = Math.floor((num / 1000000) * 10) / 10
return truncated.toFixed(1) + "M"
}

// otherwise, format as thousands
const truncated = Math.floor((num / 1000) * 10) / 10
// ensure one decimal is always shown and append "k"
return truncated.toFixed(1) + "k"
Comment on lines 106 to 115
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic change lacks test coverage. The function now has conditional branching that determines whether to format as millions or thousands, but there are no unit tests to verify this behavior works correctly for edge cases (e.g., exactly 1,000,000, values just under 1M, various million values). According to the project's Code Quality Rules, all code changes must have test coverage before completion.

Fix it with Roo Code or mention @roomote and request a fix.


// examples:
// console.log(formatNumber(1033400)) -> "1.0M"
// console.log(formatNumber(2500000)) -> "2.5M"
// console.log(formatNumber(337231)) -> "337.2k"
// console.log(formatNumber(23233)) -> "23.2k"
// console.log(formatNumber(2322)) -> "2.3k"
Expand Down
Loading