diff options
author | 2021-03-19 22:35:00 +0200 | |
---|---|---|
committer | 2021-03-19 22:35:00 +0200 | |
commit | a7c85564d90a3dc556a9582e925b33adc303de8f (patch) | |
tree | 44c5a145ccdbebabb58a33f0ca6a356487e2dc20 | |
parent | Don't reschedule reviews that are long overdue (diff) |
Review commands now use the user ID instead of nomination ID
The user ID is much more accessible, and is usually what is used to obtain the nomination ID.
-rw-r--r-- | bot/exts/recruitment/talentpool/_cog.py | 12 | ||||
-rw-r--r-- | bot/exts/recruitment/talentpool/_review.py | 34 |
2 files changed, 19 insertions, 27 deletions
diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py index f3e3539b6..b809cea17 100644 --- a/bot/exts/recruitment/talentpool/_cog.py +++ b/bot/exts/recruitment/talentpool/_cog.py @@ -302,17 +302,17 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): @nomination_group.command(aliases=('mr',)) @has_any_role(*MODERATION_ROLES) - async def mark_reviewed(self, ctx: Context, nomination_id: int) -> None: - """Mark a nomination as reviewed and cancel the review task.""" - if not await self.reviewer.mark_reviewed(ctx, nomination_id): + async def mark_reviewed(self, ctx: Context, user_id: int) -> None: + """Mark a user's nomination as reviewed and cancel the review task.""" + if not await self.reviewer.mark_reviewed(ctx, user_id): return - await ctx.send(f"✅ The nomination with ID `{nomination_id}` was marked as reviewed.") + await ctx.send(f"✅ The user with ID `{user_id}` was marked as reviewed.") @nomination_group.command(aliases=('review',)) @has_any_role(*MODERATION_ROLES) - async def post_review(self, ctx: Context, nomination_id: int) -> None: + async def post_review(self, ctx: Context, user_id: int) -> None: """Post the automatic review for the user ahead of time.""" - if not (user_id := await self.reviewer.mark_reviewed(ctx, nomination_id)): + if not await self.reviewer.mark_reviewed(ctx, user_id): return await self.reviewer.post_review(user_id, update_database=False) diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index ba1564602..c2c1312d9 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -276,37 +276,29 @@ class Reviewer: return results - async def mark_reviewed(self, ctx: Context, nomination_id: int) -> Optional[int]: + async def mark_reviewed(self, ctx: Context, user_id: int) -> bool: """ Mark an active nomination as reviewed, updating the database and canceling the review task. - On success, returns the user ID. + Returns True if the user was successfully marked as reviewed, False otherwise. """ - log.trace(f"Updating nomination #{nomination_id} as reviewed") - try: - nomination = await self.bot.api_client.get(f"{self._pool.api_endpoint}/{nomination_id}") - except ResponseCodeError as e: - if e.response.status == 404: - log.trace(f"Nomination API 404: Can't find nomination with id {nomination_id}") - await ctx.send(f"❌ Can't find a nomination with id `{nomination_id}`") - return - else: - raise + log.trace(f"Updating user {user_id} as reviewed") + await self._pool.fetch_user_cache() + if user_id not in self._pool.watched_users: + log.trace(f"Can't find a nominated user with id {user_id}") + await ctx.send(f"❌ Can't find a currently nominated user with id `{user_id}`") + return False + nomination = self._pool.watched_users[user_id] if nomination["reviewed"]: await ctx.send("❌ This nomination was already reviewed, but here's a cookie 🍪") - return - elif not nomination["active"]: - await ctx.send("❌ This nomination is inactive") - return + return False await self.bot.api_client.patch(f"{self._pool.api_endpoint}/{nomination['id']}", json={"reviewed": True}) - if nomination["user"] in self._review_scheduler: - self._review_scheduler.cancel(nomination["user"]) - - await self._pool.fetch_user_cache() + if user_id in self._review_scheduler: + self._review_scheduler.cancel(user_id) - return nomination["user"] + return True def cancel(self, user_id: int) -> None: """ |