Skip to content

Commit

Permalink
Moved db-repairs in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Dec 2, 2024
1 parent 74c52eb commit aba9424
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions sausage_bot/cogs/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion sausage_bot/util/db_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit aba9424

Please sign in to comment.