Commit 7e5d660
Fix Hunt Week double-counting of pre-game activities (#247)
* Fix Hunt Week double-counting of pre-game activities
The hunt week leaderboard reconstructed scores as initialState.points +
getPointsInPeriod(startsAt, endsAt), but initialState.points was captured
from userChallenges.totalPoints at activation time while startsAt was
midnight UTC — activities between midnight and activation were counted in
both, inflating scores unevenly across players.
Replace the reconstruction with getPointsUpToDate() which sums all
non-deleted, non-mini-game activities with loggedDate <= endsAt. This uses
a single source of truth bounded by the game end date, eliminating both
the double-count and any post-game activity leakage.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Rename getHuntWeekLeaderboard to generic getMiniGameLeaderboard
Export the function so any mini-game type can compute activity-based
standings bounded by game end date. Drop the unused startsAt param.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add hunt week audit/fix CLI for double-counting remediation
Adds internalQuery (audit) and internalMutation (fix) to check and correct
hunt week scores that were calculated with the double-counting bug. The fix
mutation supports a favorableOnly flag to only apply corrections that
increase a player's bonus points.
Shell script provides a simple CLI:
./scripts/hunt-week-audit.sh # dry run
./scripts/hunt-week-audit.sh --fix --prod # fix all on prod
./scripts/hunt-week-audit.sh --fix-favorable --prod # only increases
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add detailed correction notes to hunt week fix activities
The notes now include: original vs corrected award, rank change, the
player's recalculated points and rank, prey/hunter names with their
points and whether catch/escape occurred, and a one-line explanation
of the bug. externalData also stores corrected/previous rank.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add tests for hunt week audit and fix mutations
Tests cover:
- audit detects no discrepancies for correctly scored games
- audit detects discrepancies for buggy scores (simulated double-count)
- audit only returns completed hunt week games
- fix corrects all discrepant scores and creates correction notes
- fix with favorableOnly skips unfavorable corrections
- fix targets a specific game when miniGameId provided
- fix does not create bonus activity when correct bonus is 0
- fix updates totalPoints correctly after correction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 1f40e52 commit 7e5d660
7 files changed
Lines changed: 1316 additions & 24 deletions
File tree
- apps/web/tests/api
- packages/backend
- lib
- mutations
- scripts
- tasks
0 commit comments