aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/recruitment/talentpool/_cog.py14
-rw-r--r--bot/exts/recruitment/talentpool/_review.py56
2 files changed, 4 insertions, 66 deletions
diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py
index 1df829a84..d8dd9ff8e 100644
--- a/bot/exts/recruitment/talentpool/_cog.py
+++ b/bot/exts/recruitment/talentpool/_cog.py
@@ -163,8 +163,8 @@ class TalentPool(Cog, name="Talentpool"):
"""
Gives an overview of the nominated users list.
- It specifies the users' mention, name, how long ago they were nominated, and whether their
- review was scheduled or already posted.
+ It specifies the user's mention, name, how long ago they were nominated, and whether their
+ review was posted.
The optional kwarg `oldest_first` orders the list by oldest entry.
@@ -193,8 +193,6 @@ class TalentPool(Cog, name="Talentpool"):
line = f"~~{line}~~"
if user_data['reviewed']:
line += " *(reviewed)*"
- elif user_id in self.reviewer:
- line += " *(scheduled)*"
lines.append(line)
if not lines:
@@ -296,9 +294,6 @@ class TalentPool(Cog, name="Talentpool"):
self.cache[user.id] = response_data
- if await self.autoreview_enabled() and user.id not in self.reviewer:
- self.reviewer.schedule_review(user.id)
-
await ctx.send(f"✅ The nomination for {user.mention} has been added to the talent pool.")
@nomination_group.command(name='history', aliases=('info', 'search'))
@@ -555,9 +550,6 @@ class TalentPool(Cog, name="Talentpool"):
)
self.cache.pop(user_id)
- if await self.autoreview_enabled():
- self.reviewer.cancel(user_id)
-
return True
async def _nomination_to_string(self, nomination_object: dict) -> str:
@@ -612,4 +604,4 @@ class TalentPool(Cog, name="Talentpool"):
async def cog_unload(self) -> None:
"""Cancels all review tasks on cog unload."""
- self.reviewer.cancel_all()
+ self.autoreview_loop.stop()
diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py
index 4331a0581..c3c29fa54 100644
--- a/bot/exts/recruitment/talentpool/_review.py
+++ b/bot/exts/recruitment/talentpool/_review.py
@@ -8,9 +8,7 @@ from collections import Counter
from datetime import datetime, timedelta, timezone
from typing import List, Optional, Union
-import arrow
from botcore.site_api import ResponseCodeError
-from botcore.utils.scheduling import Scheduler
from dateutil.parser import isoparse
from discord import Embed, Emoji, Member, Message, NotFound, PartialMessage, TextChannel
from discord.ext.commands import Context
@@ -28,9 +26,6 @@ if typing.TYPE_CHECKING:
log = get_logger(__name__)
-# Maximum amount of days before an automatic review is posted.
-MAX_DAYS_IN_POOL = 30
-
# Maximum amount of characters allowed in a message
MAX_MESSAGE_SIZE = 2000
# Maximum amount of characters allowed in an embed
@@ -51,16 +46,11 @@ NOMINATION_MESSAGE_REGEX = re.compile(
class Reviewer:
- """Schedules, formats, and publishes reviews of helper nominees."""
+ """Manages, formats, and publishes reviews of helper nominees."""
def __init__(self, name: str, bot: Bot, pool: 'TalentPool'):
self.bot = bot
self._pool = pool
- self._review_scheduler = Scheduler(name)
-
- def __contains__(self, user_id: int) -> bool:
- """Return True if the user with ID user_id is scheduled for review, False otherwise."""
- return user_id in self._review_scheduler
async def maybe_review_user(self) -> bool:
"""
@@ -142,28 +132,6 @@ class Reviewer:
return user[0] # user id
- async def reschedule_reviews(self) -> None:
- """Reschedule all active nominations to be reviewed at the appropriate time."""
- log.trace("Rescheduling reviews")
- await self.bot.wait_until_guild_available()
-
- await self._pool.refresh_cache()
- for user_id, user_data in self._pool.cache.items():
- if not user_data["reviewed"]:
- self.schedule_review(user_id)
-
- def schedule_review(self, user_id: int) -> None:
- """Schedules a single user for review."""
- log.trace(f"Scheduling review of user with ID {user_id}")
-
- user_data = self._pool.cache.get(user_id)
- inserted_at = isoparse(user_data['inserted_at'])
- review_at = inserted_at + timedelta(days=MAX_DAYS_IN_POOL)
-
- # If it's over a day overdue, it's probably an old nomination and shouldn't be automatically reviewed.
- if arrow.utcnow() - review_at < timedelta(days=1):
- self._review_scheduler.schedule_at(review_at, user_id, self.post_review(user_id, update_database=True))
-
async def post_review(self, user_id: int, update_database: bool) -> None:
"""Format the review of a user and post it to the nomination voting channel."""
review, reviewed_emoji, nominee = await self.make_review(user_id)
@@ -512,27 +480,5 @@ class Reviewer:
return False
await self.bot.api_client.patch(f"bot/nominations/{nomination['id']}", json={"reviewed": True})
- if user_id in self._review_scheduler:
- self._review_scheduler.cancel(user_id)
return True
-
- def cancel(self, user_id: int) -> None:
- """
- Cancels the review of the nominee with ID `user_id`.
-
- It's important to note that this applies only until reschedule_reviews is called again.
- To permanently cancel someone's review, either remove them from the pool, or use mark_reviewed.
- """
- log.trace(f"Canceling the review of user {user_id}.")
- self._review_scheduler.cancel(user_id)
-
- def cancel_all(self) -> None:
- """
- Cancels all reviews.
-
- It's important to note that this applies only until reschedule_reviews is called again.
- To permanently cancel someone's review, either remove them from the pool, or use mark_reviewed.
- """
- log.trace("Canceling all reviews.")
- self._review_scheduler.cancel_all()