feat(aurora): add support for OFFSET
in Moderation.get_latest()
This commit is contained in:
parent
cb420d2fc4
commit
a10af37f14
1 changed files with 4 additions and 4 deletions
|
@ -229,9 +229,9 @@ class Moderation(AuroraGuildModel):
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_latest(cls, bot: Red, guild_id: int, limit: int | None = None, 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 = []
|
params = [offset]
|
||||||
query = f"SELECT * FROM moderation_{guild_id} ORDER BY moderation_id DESC"
|
query = f"SELECT * FROM moderation_{guild_id} ORDER BY moderation_id DESC OFFSET ?"
|
||||||
if limit:
|
if limit:
|
||||||
query += " LIMIT ?"
|
query += " LIMIT ?"
|
||||||
params.append(limit)
|
params.append(limit)
|
||||||
|
@ -239,7 +239,7 @@ class Moderation(AuroraGuildModel):
|
||||||
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)
|
||||||
query += ";"
|
query += ";"
|
||||||
return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=tuple(params) if limit else (), cursor=cursor)
|
return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=tuple(params) if params else (), cursor=cursor)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_next_case_number(cls, bot: Red, guild_id: int, cursor: Cursor | None = None) -> int:
|
def get_next_case_number(cls, bot: Red, guild_id: int, cursor: Cursor | None = None) -> int:
|
||||||
|
|
Loading…
Reference in a new issue