fix: leaderboard recalculation and migration crash on fresh DB#426
Open
lifeofagct wants to merge 7 commits intogenlayer-foundation:devfrom
Open
fix: leaderboard recalculation and migration crash on fresh DB#426lifeofagct wants to merge 7 commits intogenlayer-foundation:devfrom
lifeofagct wants to merge 7 commits intogenlayer-foundation:devfrom
Conversation
Refactor test setup for leaderboard recalculation to ensure default values for contribution types and categories are updated correctly. Adjust contributions and assertions in various test cases to reflect changes in points and visibility.
Refactor validator creation and contribution logic to ensure a validator profile is created if it doesn't exist, and to handle contribution creation for the validator badge.
Add tests for validator creation and leaderboard updates.
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.
This PR fixes two bugs from FIXES.md and repairs the full test suite (8/8 tests now pass).
Bug 1 - Migration 0037 crashes on fresh DB
0037_seed_featured_content.pyusedUser.objects.get()which throwsDoesNotExiston any fresh install, developer setup, or CI pipeline. Fixed with
filter().first()and an early return guard.
Bug 2 - Hardcoded leaderboard types in recalculate_all_leaderboards()
leaderboard/models.pyiterated a hardcoded list of leaderboard types when updatingranks. Any future type added to LEADERBOARD_CONFIG would silently never get its ranks
updated. Fixed by replacing the list with LEADERBOARD_CONFIG.keys().
Test suite fixes
Bug 3 - Wrong labels for Validator Waitlist users in RoleView
Waitlist users on the profile page incorrectly showed "Validator Journey",
"Total validator points" and "Validator Rank" instead of waitlist-specific
labels. Added derived variables (journeyTitle, pointsLabel, rankLabel)
that switch based on the existing isWaitlist prop.
Bug 4 - Validator Creation Shortcut not creating Validator Contribution
The admin shortcut in contributions/admin.py created a Validator profile
without the required 'validator' badge contribution, meaning the user
never appeared on the validator leaderboard.
Fix:
if it doesn't already exist
Also added validators/tests/test_validator_creation.py with 5 tests:
Files changed: