From aba9424cb0f40d0567203002da969b51bedfba15 Mon Sep 17 00:00:00 2001 From: geirawsm Date: Mon, 2 Dec 2024 09:24:35 +0100 Subject: [PATCH] Moved db-repairs in `stats` --- sausage_bot/cogs/stats.py | 13 +++++++------ sausage_bot/util/db_helper.py | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sausage_bot/cogs/stats.py b/sausage_bot/cogs/stats.py index addecd5..7cb6281 100755 --- a/sausage_bot/cogs/stats.py +++ b/sausage_bot/cogs/stats.py @@ -838,12 +838,6 @@ async def setup(bot): stats_log_inserts = stats_file_inserts['stats_logs_inserts'] log.debug(f'`stats_file_inserts` is \n{stats_file_inserts}') log.debug(f'`stats_settings_inserts` is {stats_settings_inserts}') - # Cleaning DB if irregularities from previous instances of database - if file_io.file_exist(envs.stats_db_settings_schema['db_file']): - await db_helper.db_fix_old_hide_roles_status() - await db_helper.db_fix_old_stats_msg_name_status() - await db_helper.db_fix_old_value_check_or_help() - await db_helper.db_fix_old_value_numeral_instead_of_bool() stats_settings_prep_is_ok = await db_helper.prep_table( table_in=envs.stats_db_settings_schema, inserts=stats_settings_inserts @@ -864,6 +858,13 @@ async def setup(bot): else: log.verbose('Stats db log exist!') + # Cleaning DB if irregularities from previous instances of database + if file_io.file_exist(envs.stats_db_settings_schema['db_file']): + await db_helper.db_fix_old_hide_roles_status() + await db_helper.db_fix_old_stats_msg_name_status() + await db_helper.db_fix_old_value_check_or_help() + await db_helper.db_fix_old_value_numeral_instead_of_bool() + # Delete old json files if they exist if stats_settings_prep_is_ok and file_io.file_exist(envs.stats_file): file_io.remove_file(envs.stats_file) diff --git a/sausage_bot/util/db_helper.py b/sausage_bot/util/db_helper.py index 8ad4de3..9a294b1 100755 --- a/sausage_bot/util/db_helper.py +++ b/sausage_bot/util/db_helper.py @@ -275,7 +275,8 @@ async def db_fix_old_value_numeral_instead_of_bool(): setting for setting in type_checking if type_checking[setting] != 'bool' ]: - new_bool_status.pop(setting) + if setting in new_bool_status: + new_bool_status.pop(setting) for setting in new_bool_status.copy(): print( 'Checking {}: {}'.format(