From e8866081eb16123508f54fabd8ed50ecc9c1d491 Mon Sep 17 00:00:00 2001 From: meooow25 Date: Thu, 20 Jun 2019 16:41:12 +0530 Subject: [PATCH] Correctly handle contests that were declared unrated. --- tle/util/cache_system2.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tle/util/cache_system2.py b/tle/util/cache_system2.py index 5b46df62..d996a7e5 100644 --- a/tle/util/cache_system2.py +++ b/tle/util/cache_system2.py @@ -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.