Improve output

This commit is contained in:
Maximilian Keßler 2023-11-23 00:06:00 +01:00
parent 93283c27f6
commit 1e7c6ebcf7
Signed by: max
GPG key ID: BCC5A619923C0BA5
3 changed files with 7 additions and 3 deletions

View file

@ -29,7 +29,7 @@ def read_db_config() -> DBConfig:
Reads the DB connection parameters from the config file.
"""
config_path = get_db_config_path()
logger.verbose("DB Configuration read from file {}".format(config_path))
logger.debug("DB Configuration read from file {}".format(config_path))
if config_path.exists():
with open(config_path, "r") as f:
@ -175,7 +175,7 @@ def get_config_path():
def read_config() -> Config:
config_path = get_config_path()
logger.verbose("Hanabi League configuration read from file {}".format(config_path))
logger.debug("Hanabi League configuration read from file {}".format(config_path))
if config_path.exists():
with open(config_path, "r") as f:
config = yaml.safe_load(f)

View file

@ -149,7 +149,7 @@ def add_user_name_to_player(hanabi_username: str, player_name: str):
conn_manager.get_connection().commit()
def add_player(player_name: str, user_name: str):
def add_player(user_name: str, player_name: str):
add_player_name(player_name)
add_user_name_to_player(user_name, player_name)

View file

@ -113,6 +113,8 @@ def fetch_games_for_all_players():
for game in player_games:
games[game['id']] = game
logger.info("Found {} potential league game(s) to process.".format(len(games)))
allowed_variants = database.get_variant_ids()
# This will hold the processed games that we will add to the database.
@ -123,6 +125,7 @@ def fetch_games_for_all_players():
if game_info is not None:
good_games[game_id] = game_info
logger.verbose("Found {} valid league game(s).".format(len(good_games)))
return good_games
@ -171,6 +174,7 @@ def store_new_games(games: Dict[int, GameInfo]):
"DO UPDATE SET (normalized_username, latest_game_id) = (EXCLUDED.normalized_username, EXCLUDED.latest_game_id)",
latest_game_ids.items()
)
logger.info("Added {} game(s) to database.".format(len(games)))
# We only commit after performing all insertions. This guarantees that the download table is always in sync
# with the actual games stored in the database.
conn.commit()