diff options
author | 2024-05-22 00:41:34 +0100 | |
---|---|---|
committer | 2024-05-22 03:05:53 +0100 | |
commit | 5f2bf1734c946708290cd8978ffa7a264a6acae9 (patch) | |
tree | ee2224560989027ca5e02c03f2f4928595aa9ecc | |
parent | Add new Nomination API filter to filter to active votes (diff) |
Add get_active_nomination API method for Talentpool
-rw-r--r-- | bot/exts/recruitment/talentpool/_api.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/bot/exts/recruitment/talentpool/_api.py b/bot/exts/recruitment/talentpool/_api.py index 3c0092617..476ba6b80 100644 --- a/bot/exts/recruitment/talentpool/_api.py +++ b/bot/exts/recruitment/talentpool/_api.py @@ -62,6 +62,15 @@ class NominationAPI: nomination = Nomination.model_validate(data) return nomination + async def get_active_nomination(self, user_id: int) -> Nomination | None: + """Search for an active nomination for a user and return it.""" + nominations = await self.get_nominations(user_id=user_id, active=True) + + if len(nominations) >= 1: + return nominations[0] + + return None + async def get_nomination_reason(self, user_id: int, actor_id: int) -> tuple[Nomination, str] | None: """Search for a nomination & reason for a specific actor on a specific user.""" nominations = await self.get_nominations(user_id, True) |