feat(aurora): added a return_obj parameter to Moderation.execute()
This commit is contained in:
parent
42f7f9f69b
commit
e988917319
2 changed files with 3 additions and 3 deletions
|
@ -1614,7 +1614,7 @@ class Aurora(commands.Cog):
|
||||||
continue
|
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);"
|
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
|
per_guild_completion_time = (time.time() - time_per_guild) * 1000
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|
|
@ -208,7 +208,7 @@ class Moderation(AuroraGuildModel):
|
||||||
return cls.from_dict(bot=bot, data=case)
|
return cls.from_dict(bot=bot, data=case)
|
||||||
|
|
||||||
@classmethod
|
@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
|
from ..utilities.database import connect
|
||||||
logger.trace("Executing query: %s", query)
|
logger.trace("Executing query: %s", query)
|
||||||
logger.trace("With parameters: %s", parameters)
|
logger.trace("With parameters: %s", parameters)
|
||||||
|
@ -227,7 +227,7 @@ class Moderation(AuroraGuildModel):
|
||||||
await cursor.close()
|
await cursor.close()
|
||||||
await database.close()
|
await database.close()
|
||||||
|
|
||||||
if results:
|
if results and return_obj:
|
||||||
cases = []
|
cases = []
|
||||||
for result in results:
|
for result in results:
|
||||||
case = cls.from_result(bot=bot, result=result, guild_id=guild_id)
|
case = cls.from_result(bot=bot, result=result, guild_id=guild_id)
|
||||||
|
|
Loading…
Reference in a new issue