Repository navigation
Conversation
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.
Hey team,
This implements ratability locking for rated contests as requested in #2463.
What was happening
When someone is retroactively disqualified from a contest, all future rated contests get re-rated. During re-rating,
rate_contest()previously re-evaluated each user's eligibility againstrating_floorandrating_ceilingdynamically based on their recalculatedlast_rating.If a past disqualification shifted a user's rating across the floor or ceiling boundary, participants could suddenly flip between rated and unrated after the contest was long over. For example, someone who joined a Div. 2 contest expecting to be unrated could suddenly get rated, or a rated participant could unexpectedly lose their contest rating.
What changed
ratable_usersManyToManyField onContestto track which users are eligible to be rated.contest.is_ratable_for(profile)that checks whether the contest is rated, verifies the user is not inrate_exclude, and checks that their current rating falls betweenrating_floorandrating_ceiling(defaulting newcomers to 1200 /RATING_INIT).ContestJoin.join_contest(), when a user enters as a live participant, ifcontest.is_ratable_for(profile)is True, they are added tocontest.ratable_users. This locks their ratability at the time they actually enter.rate_contest(), ifcontest.ratable_users.exists()is True, it filters participants byratable_users.all(). Ifratable_usersis empty (such as older legacy contests), it falls back to the previous dynamic floor/ceiling check for complete backward compatibility.ratable_usersto the Django admin contest form withfilter_horizontaland readonly lock enforcement.0153_contest_ratable_users.py.Testing
reproduce_dmoj_2463.py) demonstrating how retroactive rating shifts flip user status on unpatched code and stay completely stable on patched code.RatabilityLockingTestCaseinjudge/models/tests/test_contest.pycovering boundary checks, newcomer defaults, exclude lists, and queryset logic.manage.py testwith 0 failures.flake8with 0 warnings or errors.