-
-
Notifications
You must be signed in to change notification settings - Fork 313
Fix: Filter out users with empty usernames in leaderboard view #4683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Filter out users with empty usernames in leaderboard view #4683
Conversation
WalkthroughFiltering logic added to Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~8 minutes
Pre-merge checks and finishing touchesβ Failed checks (1 warning)
β Passed checks (2 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
website/views/user.py (1)
421-423: Good defensive fix for the NoReverseMatch error.The filtering logic correctly excludes users with null or empty usernames, which will prevent errors when generating profile URLs. The two separate filters make the intent clear and handle both NULL database values and empty strings.
Optional enhancement: Consider whitespace-only usernames.
If data integrity is a concern, you might also want to filter out usernames that contain only whitespace:
.filter( total_score__gt=0, username__isnull=False, ) - .exclude(username="") + .exclude(username="") + .exclude(username__regex=r'^\s+$')Alternatively, you could simplify the filters slightly:
.filter( total_score__gt=0, - username__isnull=False, ) - .exclude(username="") + .exclude(Q(username__isnull=True) | Q(username="") | Q(username__regex=r'^\s+$'))
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
π Files selected for processing (1)
website/views/user.py(1 hunks)
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run Tests
- GitHub Check: docker-test
Description:
Fixes: #4682
Found that the leaderboard was including users with empty or null usernames, which was causing a NoReverseMatch error while generating profile URLs.
Added filters in get_leaderboard to exclude such users.
This prevents the error and ensures only valid users are shown in the leaderboard.
Summary by CodeRabbit
Bug Fixes