Fix Hunt Week double-counting of pre-game activities#247
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
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>
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>
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>
5 tasks
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.
Summary
initialState.points + getPointsInPeriod(startsAt, endsAt), butinitialState.pointswas captured at activation time whilestartsAtwas midnight UTC — activities between midnight and activation were double-countedgetPointsUpToDate()which sums all non-deleted, non-mini-game activities withloggedDate <= endsAt— single source of truth, no date-boundary ambiguitygetHuntWeekLeaderboard→getMiniGameLeaderboardand exported it so any game type can use activity-based standingsscripts/hunt-week-audit.sh) with--fixand--fix-favorablemodes to remediate already-completed games_creationTime(fragile — conflates document creation time with logical activity date) and required a schema changeRemediation
After merge, run against prod:
Test plan
totalPointsdirectly🤖 Generated with Claude Code