Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Talentpool Autoreview #1459

Merged
merged 22 commits into from
Mar 19, 2021
Merged

Talentpool Autoreview #1459

merged 22 commits into from
Mar 19, 2021

Conversation

mbaruh
Copy link
Member

@mbaruh mbaruh commented Mar 11, 2021

This is blocked by python-discord/site#451

This closes #1423 and #1424

Reorganization

This PR requires the code to be split across multiple files. To avoid unnecessary file moves, I moved the files to a separate recruitment extension now instead of waiting for #1422.

Talentpool listing

  • The user's name and discriminator are now shown.
  • It is shown whether the user's automatic review is scheduled or if it was already posted.
  • Users who left the server are crossed off.

image

Questionable choices

Since the talentpool is still attached to the watch channel system (will be resolved in #1422), and the information displayed in big-brother and talentpool lists is slightly different (specifically the review info), I split the list_watched_users function into two parts, one organizing the information (prepare_watched_users_data), and one adding whatever necessary and posting it the list (list_watched_users). I then overrode (list_watched_users) in the Talentpool class. This will all probably need to be at least somewhat rewritten when the watch channel is removed.

Auto Reviewing

Once someone's name is added to the talentpool, it will now schedule an automatic review after 30 days.

The review contains details of the nominee, their nominations, the number of messages they have and the channels they're most active in, and statistics about their infractions and previous nominations.

Lastly, the bot will add three emojis to the review: A random ducky (or eyes if none found) to mark as seen, a thumbsup, and thumbsdown for the vote itself.
The code accounts for the possibility of the review being too long for a single message by splitting it where necessary.

image

The PR also adds the ability to prematurely post an automatic review with:
!talentpool review <nomination_id>

As well as being able to mark a nomination as already reviewed without posting an automatic review (e.g if someone chose to write a review themselves) by using:
!talentpool mark_reviewed <nomination_id>

Questionable choices

  • This was implemented by writing a Reviewer class, subclassing the Scheduler. This makes sense, to a degree, as its purpose is to schedule coroutine execution at a later date, and allowed me to avoid writing wrapper methods for the scheduler's cancel, cancel_all, and __contains__. This doesn't change the fact that using the scheduling methods directly on the Reviewer object and not through its added methods doesn't make immediate sense. Please judge.
  • Should those two commands work with the nomination ID, or should they work with the user ID?

This change is done in preparation to having the cog split across multiple files.
Make it a package as well so that the talentpool actually loads.
This commit adds the functionality to automatically review a nominee a
set number of days after being nominated.
This is implemented by subclassing the Scheduler and formatting a
review after 30 days.
The review contains details of the nominee, their nominations, the
number of messages they have and the channels they're most active in,
and statistics about their infractions and previous nominations.

Lastly, the bot will add three emojis to the review: eyes to mark as
seen, a thumbsup, and thumbsdown for the vote itself.
The code accounts for the possibility of the review being too long for
a single message but splitting it where necessary.
@mbaruh mbaruh changed the title Mbaruh/autoreview Talentpool Autoreview Mar 11, 2021
@mbaruh mbaruh added a: frontend Related to output and formatting p: 0 - critical Needs to be addressed ASAP t: feature New feature or request labels Mar 11, 2021
@mbaruh mbaruh linked an issue Mar 11, 2021 that may be closed by this pull request
@MarkKoz
Copy link
Member

MarkKoz commented Mar 12, 2021

I'm not sold on the current design that subclasses Scheduler. The main reason is that it doesn't provide much benefit over exposing the scheduler as an attribute. You stated yourself that it's unclear that the class is also a scheduler. If it was exposed as an attribute, the code would be more explicit.

The other issue with the design is that the subclass does a lot more than just scheduling. There's basically 1 function, schedule_review, that is directly tied to the scheduler. One may be able to argue for a subclass that only consists of that function. However, the problem is that the scheduler's other methods are still exposed. Therefore, there is still not much benefit. From an interface perspective, ideally the client would be forced to use schedule_review for all scheduling and have no way to access the regular schedule functions.

@jb3 jb3 added p: 1 - high High Priority and removed p: 0 - critical Needs to be addressed ASAP labels Mar 12, 2021
@mbaruh
Copy link
Member Author

mbaruh commented Mar 12, 2021

Hmm I get what you're saying about not subclassing it and making an attribute instead, but is it really better to apply changes to the scheduler directly from outside? I'd say it's clearer to write the methods that define how to interact with the class.

It didn't make much sense for the Reviewer to subclasses Scheduler.
The Scheduler has methods that don't make sense to use on the Reviewer directly.

There is now a Scheduler object as an attribute of the Reviewer.
Interacting with it is done by adding __contains__, cancel, and cancel_all methods.
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_cog.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_cog.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Show resolved Hide resolved
bot/exts/recruitment/talentpool/_cog.py Show resolved Hide resolved
Base automatically changed from master to main March 13, 2021 19:40
bot/exts/recruitment/talentpool/_review.py Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, thanks for doing this! Just a few minor comments.

bot/exts/moderation/watchchannels/_watchchannel.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_cog.py Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ToxicKidz ToxicKidz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good to me, a few corrections.

bot/exts/recruitment/talentpool/_cog.py Show resolved Hide resolved
bot/exts/recruitment/talentpool/_cog.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Outdated Show resolved Hide resolved
bot/exts/recruitment/talentpool/_review.py Show resolved Hide resolved
mbaruh and others added 2 commits March 19, 2021 17:55
Co-authored-by: ToxicKidz <78174417+ToxicKidz@users.noreply.github.com>
Copy link
Contributor

@ToxicKidz ToxicKidz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Uncached mentions render as 'invalid' users on mobile, and with the list now showing the user's name we can now just show the ID without many problems.
This is necessary as otherwise the bot would try to review them every time it restarts
If it's been over a day overdue for a review, don't reschedule it.
This is done in order to not fire reviews for all nominations which
are over 30 days old when the auto-reviewing feature is merged.
@mbaruh mbaruh requested a review from wookie184 March 19, 2021 18:53
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

The user ID is much more accessible, and is usually what is used to obtain the nomination ID.
@jb3 jb3 merged commit 207a591 into main Mar 19, 2021
@jb3 jb3 deleted the mbaruh/autoreview branch March 19, 2021 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: frontend Related to output and formatting p: 1 - high High Priority t: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically put nominated users up for vote Fix tp list command
6 participants