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 fixes #2414 so contests that haven't been rated yet aren't prematurely rated when re-rating after a disqualification.
What was happening
When a user is disqualified from a past contest,
contest.rate()runs to recalculate ratings for that contest and every later contest up to the current time. The query previously grabbed all contests whereis_rated=Truein(self.end_time, self._now)without checking if those contests had ever been rated yet.If a contest finished recently but organizers were still holding off on rating it (for example, while reviewing plagiarism or waiting on editorial releases), re-rating an older contest would prematurely publish ratings for that newer contest.
What changed
In
judge/models/contest.py, I updatedContest.rate():self(to ensure the target contest is always rated, even when rating it for the first time) or contests that already have ratings (ratings__isnull=False):contestsinto a list before deleting old ratings, ensuringRating.objects.filter(contest__in=contests).delete()only targets the contests that are actually being re-rated, without wiping out the query's ability to detect which contests were already rated.Testing
reproduce_dmoj_2414.py) confirming that an unrated contest in the time window is prematurely rated on unpatched code and cleanly skipped on patched code.ContestRateTestCaseinjudge/models/tests/test_contest.pytesting theQfilter expression and verifying that onlyselfand already-rated contests are deleted and passed torate_contest().manage.py testwith 0 errors.flake8with 0 warnings.