add function to process all games for rating

This commit is contained in:
Maximilian Keßler 2023-11-23 18:38:34 +01:00
parent 4d6fedf768
commit cabec71e4f
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -118,11 +118,11 @@ def get_current_variant_rating(variant_id: int, num_players: int) -> float:
return base_rating return base_rating
def process_rating_of_next_game(): def process_rating_of_next_game() -> bool:
game_id = next_game_to_rate() game_id = next_game_to_rate()
if game_id is None: if game_id is None:
logger.verbose("All games already processed for rating changes.") logger.verbose("All games already processed for rating changes.")
return return False
logger.verbose("Processing rating for game {}".format(game_id)) logger.verbose("Processing rating for game {}".format(game_id))
cur = conn_manager.get_new_cursor() cur = conn_manager.get_new_cursor()
@ -180,3 +180,14 @@ def process_rating_of_next_game():
user_ratings_vals user_ratings_vals
) )
conn_manager.get_connection().commit() 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