Skip to content

Commit c688a64

Browse files
fix: display install count in millions instead of thousands (#9677)
Co-authored-by: Roo Code <[email protected]>
1 parent 127ecf6 commit c688a64

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/web-roo-code/src/lib/stats.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ export async function getVSCodeDownloads() {
104104
}
105105

106106
function formatNumber(num: number): string {
107-
// divide by 1000 to convert to "thousands" format,
108-
// multiply by 10, floor the result, then divide by 10 to keep one decimal place.
107+
// if number is 1 million or more, format as millions
108+
if (num >= 1000000) {
109+
const truncated = Math.floor((num / 1000000) * 10) / 10
110+
return truncated.toFixed(1) + "M"
111+
}
112+
113+
// otherwise, format as thousands
109114
const truncated = Math.floor((num / 1000) * 10) / 10
110-
// ensure one decimal is always shown and append "k"
111115
return truncated.toFixed(1) + "k"
112116

113117
// examples:
118+
// console.log(formatNumber(1033400)) -> "1.0M"
119+
// console.log(formatNumber(2500000)) -> "2.5M"
114120
// console.log(formatNumber(337231)) -> "337.2k"
115121
// console.log(formatNumber(23233)) -> "23.2k"
116122
// console.log(formatNumber(2322)) -> "2.3k"

0 commit comments

Comments
 (0)