Skip to content

fix: don't flag every user as NEW when yesterday snapshot is unavailable - #421

Open
vedant7007 wants to merge 1 commit into
codepvg:mainfrom
vedant7007:fix/rank-change-snapshot-guard
Open

fix: don't flag every user as NEW when yesterday snapshot is unavailable#421
vedant7007 wants to merge 1 commit into
codepvg:mainfrom
vedant7007:fix/rank-change-snapshot-guard

Conversation

@vedant7007

Copy link
Copy Markdown
Contributor

Problem

computeRankChanges() in scripts/sync-leaderboard.js starts with an empty previousRanks and only fills it when getYesterdaySnapshot() returns an array. That helper returns null on any error (network, GitHub API, rate-limit, missing commit). On a transient failure previousRanks stays empty, so the loop hits previousRanks[user.id] === undefined for every user and sets rankChange = "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

  • Neutral 0 is the same value the existing delta-is-zero path already produces, so the frontend renders it as "no change" (not a false "NEW").
  • Syntax-checked with node --check.

Closes #378

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
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
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

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Data-integrity] Transient yesterday-snapshot failure flags every user as NEW, erasing rank arrows

1 participant