From cabec71e4f405b82c11b8e1785b2e5750b88c70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 23 Nov 2023 18:38:34 +0100 Subject: [PATCH] add function to process all games for rating --- src/ratings.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ratings.py b/src/ratings.py index 25d7580..7d1cc03 100644 --- a/src/ratings.py +++ b/src/ratings.py @@ -118,11 +118,11 @@ def get_current_variant_rating(variant_id: int, num_players: int) -> float: return base_rating -def process_rating_of_next_game(): +def process_rating_of_next_game() -> bool: game_id = next_game_to_rate() if game_id is None: logger.verbose("All games already processed for rating changes.") - return + return False logger.verbose("Processing rating for game {}".format(game_id)) cur = conn_manager.get_new_cursor() @@ -180,3 +180,14 @@ def process_rating_of_next_game(): user_ratings_vals ) conn_manager.get_connection().commit() + return True + + +def process_rating_of_all_games(): + # It might seem a bit tedious of processing every single game separately, + # which means reading and writing to the database more than we would strictly need. + # However, since we have such a small number of games, this is fast enough without problems, + # and makes the program structure easier, therefore avoiding mistakes and improving granularity + # of our database updates. + while process_rating_of_next_game(): + pass