Skip to content

Commit

Permalink
Correctly handle contests that were declared unrated.
Browse files Browse the repository at this point in the history
  • Loading branch information
meooow25 authored and algmyr committed Jun 21, 2019
1 parent b5f0e6f commit e886608
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tle/util/cache_system2.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,17 @@ async def generate_ranklist(self, contest_id, *, fetch_changes=False, predict_ch
if fetch_changes:
# Fetch final rating changes from CF.
# For older contests.
is_rated = False
try:
changes = await cf.contest.ratingChanges(contest_id=contest_id)
# For contests intended to be rated but declared unrated, an empty list is returned.
is_rated = len(changes) > 0
except cf.RatingChangesUnavailableError:
ranklist = Ranklist(contest, problems, standings, now, is_rated=False)
else:
pass
ranklist = Ranklist(contest, problems, standings, now, is_rated=is_rated)
if is_rated:
delta_by_handle = {change.handle: change.newRating - change.oldRating
for change in changes}
ranklist = Ranklist(contest, problems, standings, now, is_rated=True)
ranklist.set_deltas(delta_by_handle)
elif predict_changes:
# Rating changes have not been applied yet, predict rating changes.
Expand Down

0 comments on commit e886608

Please sign in to comment.