fix(aurora): fixed an sql operation error
All checks were successful
Actions / Build Documentation (MkDocs) (pull_request) Successful in 30s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 46s

This commit is contained in:
Seaswimmer 2024-06-04 12:29:24 -04:00
parent 19e50c25e3
commit 38180f5ccd
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -230,14 +230,14 @@ class Moderation(AuroraGuildModel):
@classmethod
def get_latest(cls, bot: Red, guild_id: int, limit: int | None = None, offset: int = 0, types: Iterable | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]:
params = [offset]
query = f"SELECT * FROM moderation_{guild_id} ORDER BY moderation_id DESC OFFSET ?"
if limit:
query += " LIMIT ?"
params.append(limit)
params = []
query = f"SELECT * FROM moderation_{guild_id} ORDER BY moderation_id DESC"
if types:
query += f" WHERE moderation_type IN ({', '.join(['?' for _ in types])})"
params.extend(types)
if limit:
query += " LIMIT ? OFFSET ?"
params.extend((limit, offset))
query += ";"
return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=tuple(params) if params else (), cursor=cursor)