aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2022-10-23 11:25:58 +0100
committerGravatar wookie184 <[email protected]>2022-10-23 11:25:58 +0100
commit6f7702f1ac40cf3a10853caaabdce8020f3f825c (patch)
treec9765674be61de27f8055b7bbd8906c89f4761d9
parentFix tests (diff)
Various improvements and fixes
-rw-r--r--bot/exts/recruitment/talentpool/_api.py22
-rw-r--r--bot/exts/recruitment/talentpool/_cog.py15
-rw-r--r--poetry.lock2
-rw-r--r--pyproject.toml2
4 files changed, 22 insertions, 19 deletions
diff --git a/bot/exts/recruitment/talentpool/_api.py b/bot/exts/recruitment/talentpool/_api.py
index 85dadb0f6..c89fa0875 100644
--- a/bot/exts/recruitment/talentpool/_api.py
+++ b/bot/exts/recruitment/talentpool/_api.py
@@ -19,7 +19,7 @@ class Nomination(BaseModel):
active: bool
user_id: int = Field(alias="user")
inserted_at: datetime
- end_reason: str | None
+ end_reason: str
ended_at: datetime | None
entries: list[NominationEntry]
reviewed: bool
@@ -35,7 +35,7 @@ class NominationAPI:
self,
user_id: int | None = None,
active: bool | None = None,
- ordering: str = '-inserted_at'
+ ordering: str = "-inserted_at"
) -> list[Nomination]:
"""
Fetch a list of nominations.
@@ -48,7 +48,7 @@ class NominationAPI:
if user_id is not None:
params["user__id"] = str(user_id)
- data = await self.site_api.get('bot/nominations', params=params)
+ data = await self.site_api.get("bot/nominations", params=params)
nominations = parse_obj_as(list[Nomination], data)
return nominations
@@ -65,7 +65,7 @@ class NominationAPI:
end_reason: str | None = None,
active: bool | None = None,
reviewed: bool | None = None,
- ) -> None:
+ ) -> Nomination:
"""
Edit a nomination entry.
@@ -75,11 +75,12 @@ class NominationAPI:
if end_reason is not None:
data["end_reason"] = end_reason
if active is not None:
- data["active"] = str(active)
+ data["active"] = active
if reviewed is not None:
- data["reviewed"] = str(reviewed)
+ data["reviewed"] = reviewed
- await self.site_api.patch(f"bot/nominations/{nomination_id}", json=data)
+ result = await self.site_api.patch(f"bot/nominations/{nomination_id}", json=data)
+ return Nomination.parse_obj(result)
async def edit_nomination_entry(
self,
@@ -87,10 +88,11 @@ class NominationAPI:
*,
actor_id: int,
reason: str,
- ) -> None:
+ ) -> Nomination:
"""Edit a nomination entry."""
- data = {"actor": str(actor_id), "reason": reason}
- await self.site_api.patch(f"bot/nominations/{nomination_id}", json=data)
+ data = {"actor": actor_id, "reason": reason}
+ result = await self.site_api.patch(f"bot/nominations/{nomination_id}", json=data)
+ return Nomination.parse_obj(result)
async def post_nomination(
self,
diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py
index b81411c29..f1614f284 100644
--- a/bot/exts/recruitment/talentpool/_cog.py
+++ b/bot/exts/recruitment/talentpool/_cog.py
@@ -152,7 +152,7 @@ class TalentPool(Cog, name="Talentpool"):
The optional kwarg `oldest_first` orders the list by oldest entry.
"""
- nominations = await self.api.get_nominations()
+ nominations = await self.api.get_nominations(active=True)
if oldest_first:
nominations = reversed(nominations)
@@ -182,8 +182,8 @@ class TalentPool(Cog, name="Talentpool"):
@nomination_group.command(name='oldest')
@has_any_role(*MODERATION_ROLES)
async def oldest_command(self, ctx: Context) -> None:
- """Shows talent pool users ordered by oldest nomination."""
- await ctx.invoke(self.list_command, oldest_first=True)
+ """Shows the users that are currently in the talent pool, ordered by oldest nomination."""
+ await self.list_nominated_users(ctx, oldest_first=True)
@nomination_group.command(
name="forcenominate",
@@ -419,7 +419,7 @@ class TalentPool(Cog, name="Talentpool"):
"""Get the user's review as a markdown file."""
nominations = await self.api.get_nominations(user_id, active=True)
if not nominations:
- await ctx.send(f"There doesn't appear to be an active nomination for {user_id}")
+ await ctx.send(f":x: There doesn't appear to be an active nomination for {user_id}")
return
review, _, _ = await self.reviewer.make_review(nominations[0])
@@ -432,12 +432,13 @@ class TalentPool(Cog, name="Talentpool"):
"""Post the automatic review for the user ahead of time."""
nominations = await self.api.get_nominations(user_id, active=True)
if not nominations:
- await ctx.send(f"There doesn't appear to be an active nomination for {user_id}")
+ await ctx.send(f":x: There doesn't appear to be an active nomination for {user_id}")
return
nomination = nominations[0]
if nomination.reviewed:
await ctx.send(":x: This nomination was already reviewed, but here's a cookie :cookie:")
+ return
await self.reviewer.post_review(nomination)
await ctx.message.add_reaction(Emojis.check_mark)
@@ -475,7 +476,7 @@ class TalentPool(Cog, name="Talentpool"):
active_nominations = await self.api.get_nominations(user_id, active=True)
if not active_nominations:
- log.debug(f"No active nominate exists for {user_id=}")
+ log.debug(f"No active nomination exists for {user_id=}")
return False
log.info(f"Ending nomination: {user_id=} {reason=}")
@@ -537,4 +538,4 @@ class TalentPool(Cog, name="Talentpool"):
"""Cancels the autoreview loop on cog unload."""
# Only cancel the loop task when the autoreview code is not running
async with self.autoreview_lock:
- self.autoreview_loop_lock.cancel()
+ self.autoreview_loop.cancel()
diff --git a/poetry.lock b/poetry.lock
index 766cb16c4..5df497649 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1135,7 +1135,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "3.10.*"
-content-hash = "95824d80252e2b494ba9520e8d5f6fa0a57e2f747b32dd77d90be471a231bbfa"
+content-hash = "f7c3aa7385e92837d5f8401f9903375a20881ad2d21aeeda56c9e374e3c46918"
[metadata.files]
aiodns = [
diff --git a/pyproject.toml b/pyproject.toml
index b6288e573..2019d847a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -36,7 +36,7 @@ regex = "2022.9.13"
sentry-sdk = "1.9.10"
statsd = "3.3.0"
tldextract = "3.4.0"
-pydantic = "^1.10.2"
+pydantic = "1.10.2"
[tool.poetry.dev-dependencies]
coverage = "6.5.0"