-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add top-helpers command #282
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
marko-radosavljevic
added
new command
Add a new command or group of commands to the bot
priority: major
labels
Nov 26, 2021
This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Valid but parked, will be picked up by someone soonish (january maybe). |
Zabuzard
added
the
blocked
This issue is currently blocked by another issue (see comments)
label
Jan 21, 2022
Will take this over but for the moment blocked by #345. |
Zabuzard
removed
the
blocked
This issue is currently blocked by another issue (see comments)
label
Jan 27, 2022
Zabuzard
force-pushed
the
feature/top-helpers
branch
2 times, most recently
from
January 27, 2022 11:44
e83c4f8
to
306f674
Compare
Zabuzard
force-pushed
the
feature/top-helpers
branch
2 times, most recently
from
January 27, 2022 17:13
3998789
to
3a76f0c
Compare
Zabuzard
requested review from
Zabuzard,
d3vel0per,
Heatmanofurioso and
Tais993
January 27, 2022 18:20
Zabuzard
previously approved these changes
Jan 27, 2022
* changed the layout of the methods * fixed style issues * fixed various design issues * streamlined the code more the logic itself merely changed
* with proper java.time computation instead of just "last 30 days"
Zabuzard
force-pushed
the
feature/top-helpers
branch
from
February 2, 2022 11:32
a5bfabd
to
1241d05
Compare
Kudos, SonarCloud Quality Gate passed! |
No changes since a week, merging. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Implements and closes #65. Originally based on #117.
Adds the
/top-helpers
command that computes and displays the top helpers from the last month.Also has a fallback message if there is no data in the time range yet:
For now the command has no options but it was designed with optionally picking a time range (start and end) in mind. This can be done once Discord/JDA add date-pickers (currently in progress). A
TODO
in the class keeps track of this.Details
The code is divided into three classes:
TopHelpersCommand
- the slash command itself, will read the database, compute the message and display itTopHelpersMessageListener
- the listener that receives all help messages and adjusts the database accordinglyTopHelpersPurgeMessagesRoutine
- the routine that deletes old messages from the databaseSlash command
The
TopHelpersCommand
class is pretty straightforward:java.time
and not just last 30 days)groupBy
withcount
andorderBy
, nothing fancy)Member
information about those users asyncAsciiTable
libraryMessage listener
The
TopHelpersMessageListener
class has one simple jobs right now:latter should in the near future be replaced with #346 , aTODO
keeps track of it already.Help messages are identified by channel name regex (as per
MessageReceiverAdapter
), the regex is:In the future,
FreeCommand
could be changed to utilize this config entry as well, instead of the channel ids.Message purging
The class
TopHelpersPurgeMessagesRoutine
is a simpleRoutine
which is executed once every 4 hours and deletes all top-helper message entries in the database that are older than 90 days.Database
The database table that supports all the magic is quite simple, its just:
Remarks for release
The config has changed, the following has been added:
(see the
config.json.template
file in the code diff)