feat(aurora): added a return_obj parameter to Moderation.execute()

This commit is contained in:
Seaswimmer 2024-06-05 01:31:40 -04:00
parent 42f7f9f69b
commit e988917319
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 3 additions and 3 deletions

View file

@ -1614,7 +1614,7 @@ class Aurora(commands.Cog):
continue
expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp IS NOT NULL AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1);"
await Moderation.execute(bot=self.bot, guild_id=guild.id, query=expiry_query, parameters=(time.time(),))
await Moderation.execute(bot=self.bot, guild_id=guild.id, query=expiry_query, parameters=(time.time(),), return_obj=False)
per_guild_completion_time = (time.time() - time_per_guild) * 1000
logger.debug(

View file

@ -208,7 +208,7 @@ class Moderation(AuroraGuildModel):
return cls.from_dict(bot=bot, data=case)
@classmethod
async def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]:
async def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None, cursor: Cursor | None = None, return_obj: bool = True) -> Tuple["Moderation"]:
from ..utilities.database import connect
logger.trace("Executing query: %s", query)
logger.trace("With parameters: %s", parameters)
@ -227,7 +227,7 @@ class Moderation(AuroraGuildModel):
await cursor.close()
await database.close()
if results:
if results and return_obj:
cases = []
for result in results:
case = cls.from_result(bot=bot, result=result, guild_id=guild_id)