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