WIP: Refactor Aurora (3.0.0) #29
1 changed files with 5 additions and 5 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue