fix: display install count in millions instead of thousands (#9677)

Co-authored-by: Roo Code <roomote@roocode.com>
This commit is contained in:
roomote[bot] 2025-11-28 20:36:34 -05:00 committed by GitHub
parent 127ecf6ddd
commit c688a6466e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"
// 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"