fix: don't flag every user as NEW when yesterday snapshot is unavailable - #421
Open
vedant7007 wants to merge 1 commit into
Open
fix: don't flag every user as NEW when yesterday snapshot is unavailable#421vedant7007 wants to merge 1 commit into
vedant7007 wants to merge 1 commit into
Conversation
computeRankChanges() started with an empty previousRanks and only filled it when getYesterdaySnapshot() returned an array. That helper returns null on any error (network, GitHub API, rate-limit, missing commit), so a single transient failure left previousRanks empty and set rankChange = "NEW" for every user, wiping all up/down arrows. The result is persisted to JSON, so one hiccup sticks until the next clean run. Guard the null/non-array case: leave rank changes neutral (0) and warn, instead of fabricating a board-wide "NEW". Closes codepvg#378
Contributor
|
Thank you for submitting a pull request. Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully. Formatting and Branching
|
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.
Problem
computeRankChanges()inscripts/sync-leaderboard.jsstarts with an emptypreviousRanksand only fills it whengetYesterdaySnapshot()returns an array. That helper returnsnullon any error (network, GitHub API, rate-limit, missing commit). On a transient failurepreviousRanksstays empty, so the loop hitspreviousRanks[user.id] === undefinedfor every user and setsrankChange = "NEW"— wiping all up/down arrows. Because the result is persisted to JSON, one hiccup sticks until the next clean run.Fix
Guard the null / non-array case: warn and leave rank changes neutral (
0) instead of fabricating a board-wide"NEW". When the previous snapshot genuinely loads, behaviour is unchanged.Notes
0is the same value the existing delta-is-zero path already produces, so the frontend renders it as "no change" (not a false "NEW").node --check.Closes #378