Conversation
replaces fetching metrics directly from database instead of discord, uses embed for showcases stats and making duration as optional choice in terms of days
spotless fixes, helper for calculating duration in seconds between datetime fields to be more compliant with code quality tests
change emojis to unicode character constants with descriptive names, single/blank line of space to be more intentional and clear
tj-wazei
left a comment
There was a problem hiding this comment.
I think this is fine, just some small changes to the imports.
application/src/main/java/org/togetherjava/tjbot/features/Features.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
SquidXTV
left a comment
There was a problem hiding this comment.
Good job!
I kinda abused some review comments for future ideas and questions.
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
…/HelpThreadStatsCommand.java use a more simpler way to get days and a fallback if user entered option is missing Co-authored-by: Connor Schweighöfer <squidxtv@gmail.com>
since when saving thread meta data, participant count excludes author which means thread with 0 participants should be counted as ghost threads instead of single participant
to avoid users from spamming, this adds a cooldown period of a min per channel
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
uses Duration instance for expiration of cache items instead of seperate values for ease of maintenance and clarity
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadStatsCommand.java
Outdated
Show resolved
Hide resolved
utf code with actual emojis for clarity, break onSlash handler into more helpers update helpthreadlistener to only store true participant count in database
adds helper function in HelpThreadLifecycleListener to get nonBot participant for database updates
| int messageCount = threadChannel.getMessageCount(); // TODO: to be replaced with participant | ||
| // message count |
There was a problem hiding this comment.
dangling todo. will this be done in this PR or in another? consider maybe making a gh issue if latter
| long secondsSinceLastUsage = getSecondsSinceLastUsage(channelId, now); | ||
| if (secondsSinceLastUsage != 0L) { |
There was a problem hiding this comment.
i dont quite get this. feels to me like ur abusing 0 as magic value to indicate something.
like, lets say i used the command 2 days ago, then a method named getSecondsSinceLastUsage should return me the seconds equivalent for 2 days and not 0.
consider renaming this to maybe getSecondsStillOnCooldown or something similar
| double helpThreadInteractionRate = totalHelpThreadsCreated > 0 | ||
| ? ((double) (totalHelpThreadsCreated - ghostThreads) / totalHelpThreadsCreated) | ||
| * 100 | ||
| : -1; |
There was a problem hiding this comment.
whats this? definitely needs a good name (or helper method) so this "formula" is easy to understand at first glance.
| .where(HELP_THREADS.CREATED_AT.ge(startDate)) | ||
| .where(HELP_THREADS.CREATED_AT.ge(statsDurationStartDate)) | ||
| .fetchOne(); | ||
|
|
||
| if (statsRecord == null || statsRecord.get(TOTAL_CREATED_FIELD, Integer.class) == 0) { | ||
| event.getHook() | ||
| .editOriginal("No stats available for the last " + days + " days.") | ||
| .queue(); | ||
| return null; | ||
| return Optional.empty(); |
There was a problem hiding this comment.
im pretty sure there is some variant of that fetchOne() that also returns an Optional already. in which case the code below could be simplified by using the optional-api instead
continues work of #1159 with /help-stats slash command, refactors to fetch stats from database instead of discord APIs. Also adds stats to embed for better UX.
embed color has three states
edited: also adds per channel limit, can be used once per minute.