feat(aurora): added more debug logging for the handle_expiry task

This commit is contained in:
Seaswimmer 2024-01-02 03:34:14 -05:00
parent 50c5785245
commit a0a7d397a7
Signed by untrusted user: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -946,6 +946,7 @@ class Aurora(commands.Cog):
current_time = time.time() current_time = time.time()
database = connect() database = connect()
cursor = database.cursor() cursor = database.cursor()
global_num = 0
guilds: list[discord.Guild] = self.bot.guilds guilds: list[discord.Guild] = self.bot.guilds
for guild in guilds: for guild in guilds:
@ -963,6 +964,7 @@ class Aurora(commands.Cog):
target_ids = [row[0] for row in result] target_ids = [row[0] for row in result]
moderation_ids = [row[1] for row in result] moderation_ids = [row[1] for row in result]
num = 0
for target_id, moderation_id in zip(target_ids, moderation_ids): for target_id, moderation_id in zip(target_ids, moderation_ids):
user: discord.User = await self.bot.fetch_user(target_id) user: discord.User = await self.bot.fetch_user(target_id)
try: try:
@ -974,6 +976,9 @@ class Aurora(commands.Cog):
await user.send(embed=embed) await user.send(embed=embed)
except discord.errors.HTTPException: except discord.errors.HTTPException:
pass pass
logger.debug("Unbanned %s#%s (%s) from %s (%s)", user.name, user.discriminator, user.id, guild.name, guild.id)
num = num + 1
except (discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException) as e: except (discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException) as e:
logger.error("Failed to unban %s#%s (%s) from %s (%s)\n%s", user.name, user.discriminator, user.id, guild.name, guild.id, e) logger.error("Failed to unban %s#%s (%s) from %s (%s)\n%s", user.name, user.discriminator, user.id, guild.name, guild.id, e)
@ -1001,14 +1006,15 @@ class Aurora(commands.Cog):
continue continue
per_guild_completion_time = (time.time() - time_per_guild) * 1000 per_guild_completion_time = (time.time() - time_per_guild) * 1000
logger.debug("Completed expiry loop for %s (%s) in %sms", guild.name, guild.id, f"{per_guild_completion_time:.6f}") logger.debug("Completed expiry loop for %s (%s) in %sms with %s users unbanned", guild.name, guild.id, f"{per_guild_completion_time:.6f}, num")
global_num = global_num + num
database.commit() database.commit()
cursor.close() cursor.close()
database.close() database.close()
completion_time = (time.time() - current_time) * 1000 completion_time = (time.time() - current_time) * 1000
logger.debug("Completed expiry loop in %sms", f"{completion_time:.6f}") logger.debug("Completed expiry loop in %sms with %s users unbanned", f"{completion_time:.6f}", global_num)
####################################################################################################################### #######################################################################################################################
### CONFIGURATION COMMANDS ### CONFIGURATION COMMANDS