fix: star count shouldn't round down near the next thousand - #2421
Open
theluckystrike wants to merge 1 commit into
Open
theluckystrike wants to merge 1 commit into
theluckystrike wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The star count on the site rounds down near the top of each thousand: with 16,960 stars it shows "16k" instead of "17k".
formatStarCountcalls(count / 1000).toFixed(1), which gives "17.0" for 16,960. When that string ends in ".0", the old code built the label fromMath.floor(count / 1000)instead, which drops the rounding and prints 16. So any count from x,950 to x,999 came out one thousand too low.The fix keeps the
toFixed(1)value and just strips a trailing ".0", so 16,960 becomes "17k" while 16,000 stays "16k". That's it.Tests: I added
apps/web/__tests__/unit/github-star-count.test.tswith 7 assertions (0, 999, 16,420, 16,000, 16,049, 16,960, 19,999). The 16,960 and 19,999 cases fail on main ("16k" and "19k") and pass with this change.biome checkis clean on both files.The PR appears safe to merge.
Summary
The PR preserves the rounded value when formatting GitHub star counts and adds tests for the affected boundaries.
Reviews (1) · Last reviewed commit: "fix: star count shouldn't round down nea..."