From a10af37f143528420c67c99d89e3eb6757bae05e Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 4 Jun 2024 12:23:12 -0400 Subject: [PATCH] feat(aurora): add support for `OFFSET` in `Moderation.get_latest()` --- aurora/models/moderation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aurora/models/moderation.py b/aurora/models/moderation.py index 5462ba3..bb36a90 100644 --- a/aurora/models/moderation.py +++ b/aurora/models/moderation.py @@ -229,9 +229,9 @@ class Moderation(AuroraGuildModel): return () @classmethod - def get_latest(cls, bot: Red, guild_id: int, limit: int | None = None, types: Iterable | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]: - params = [] - query = f"SELECT * FROM moderation_{guild_id} ORDER BY moderation_id DESC" + 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) @@ -239,7 +239,7 @@ class Moderation(AuroraGuildModel): query += f" WHERE moderation_type IN ({', '.join(['?' for _ in types])})" params.extend(types) 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 def get_next_case_number(cls, bot: Red, guild_id: int, cursor: Cursor | None = None) -> int: