WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit 38180f5ccd - Show all commits

View file

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