fix(aurora): added more verbose debug logging to the expiry task
This commit is contained in:
parent
dc8138bd89
commit
67142c6458
1 changed files with 14 additions and 6 deletions
|
@ -1628,7 +1628,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
|
unban_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)
|
||||||
name = (
|
name = (
|
||||||
|
@ -1660,7 +1660,7 @@ class Aurora(commands.Cog):
|
||||||
guild.name,
|
guild.name,
|
||||||
guild.id,
|
guild.id,
|
||||||
)
|
)
|
||||||
num = num + 1
|
unban_num = unban_num + 1
|
||||||
except (
|
except (
|
||||||
discord.errors.NotFound,
|
discord.errors.NotFound,
|
||||||
discord.errors.Forbidden,
|
discord.errors.Forbidden,
|
||||||
|
@ -1675,6 +1675,7 @@ class Aurora(commands.Cog):
|
||||||
e,
|
e,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
removerole_num = 0
|
||||||
addrole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'ADDROLE' AND expired = 0"
|
addrole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'ADDROLE' AND expired = 0"
|
||||||
try:
|
try:
|
||||||
cursor.execute(addrole_query, (time.time(),))
|
cursor.execute(addrole_query, (time.time(),))
|
||||||
|
@ -1699,6 +1700,8 @@ class Aurora(commands.Cog):
|
||||||
await member.remove_roles(
|
await member.remove_roles(
|
||||||
role, reason=f"Automatic role removal from case #{moderation_id}"
|
role, reason=f"Automatic role removal from case #{moderation_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
removerole_num = removerole_num + 1
|
||||||
except (
|
except (
|
||||||
discord.errors.NotFound,
|
discord.errors.NotFound,
|
||||||
discord.errors.Forbidden,
|
discord.errors.Forbidden,
|
||||||
|
@ -1706,6 +1709,7 @@ class Aurora(commands.Cog):
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
addrole_num = 0
|
||||||
removerole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'REMOVEROLE' AND expired = 0"
|
removerole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'REMOVEROLE' AND expired = 0"
|
||||||
try:
|
try:
|
||||||
cursor.execute(removerole_query, (time.time(),))
|
cursor.execute(removerole_query, (time.time(),))
|
||||||
|
@ -1730,6 +1734,8 @@ class Aurora(commands.Cog):
|
||||||
await member.add_roles(
|
await member.add_roles(
|
||||||
role, reason=f"Automatic role addition from case #{moderation_id}"
|
role, reason=f"Automatic role addition from case #{moderation_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
addrole_num = addrole_num + 1
|
||||||
except (
|
except (
|
||||||
discord.errors.NotFound,
|
discord.errors.NotFound,
|
||||||
discord.errors.Forbidden,
|
discord.errors.Forbidden,
|
||||||
|
@ -1742,13 +1748,15 @@ class Aurora(commands.Cog):
|
||||||
|
|
||||||
per_guild_completion_time = (time.time() - time_per_guild) * 1000
|
per_guild_completion_time = (time.time() - time_per_guild) * 1000
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Completed expiry loop for %s (%s) in %sms with %s users unbanned",
|
"Completed expiry loop for %s (%s) in %sms with %s users unbanned, %s roles added, and %s roles removed",
|
||||||
guild.name,
|
guild.name,
|
||||||
guild.id,
|
guild.id,
|
||||||
f"{per_guild_completion_time:.6f}",
|
f"{per_guild_completion_time:.6f}",
|
||||||
num,
|
unban_num,
|
||||||
|
addrole_num,
|
||||||
|
removerole_num,
|
||||||
)
|
)
|
||||||
global_num = global_num + num
|
global_num = global_num + unban_num + addrole_num + removerole_num
|
||||||
|
|
||||||
database.commit()
|
database.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
@ -1756,7 +1764,7 @@ class Aurora(commands.Cog):
|
||||||
|
|
||||||
completion_time = (time.time() - current_time) * 1000
|
completion_time = (time.time() - current_time) * 1000
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Completed expiry loop in %sms with %s users unbanned",
|
"Completed expiry loop in %sms with %s users unbanned, %s roles added, and %s roles removed",
|
||||||
f"{completion_time:.6f}",
|
f"{completion_time:.6f}",
|
||||||
global_num,
|
global_num,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue