-
-
Notifications
You must be signed in to change notification settings - Fork 92
Add tophelpers command 🏆 #117
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also maybe put the things into a different gradle module?
application/src/test/java/org/togetherjava/tjbot/commands/TopHelpersTest.java
Outdated
Show resolved
Hide resolved
application/src/test/java/org/togetherjava/tjbot/db/MessageMetadataListenerTest.java
Outdated
Show resolved
Hide resolved
application/src/test/java/org/togetherjava/tjbot/db/MessageMetadataListenerTest.java
Outdated
Show resolved
Hide resolved
application/src/test/java/org/togetherjava/tjbot/db/MessageMetadataListenerTest.java
Outdated
Show resolved
Hide resolved
application/src/test/java/org/togetherjava/tjbot/db/MessageMetadataListenerTest.java
Outdated
Show resolved
Hide resolved
application/src/test/java/org/togetherjava/tjbot/db/MessageMetadataListenerTest.java
Outdated
Show resolved
Hide resolved
b35f4e2
to
d6dbd6e
Compare
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for using longs for ID's!
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/db/MessageMetadataListener.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/db/MessageMetadataListener.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/util/PresentationUtils.java
Show resolved
Hide resolved
application/src/main/resources/db/V2__table_message_metadata.sql
Outdated
Show resolved
Hide resolved
Changed to draft. Should not be merged. |
@d3vel0per Any news on this? |
Yes, I am waiting for: Since both will need merges at my end. |
Tell me if you need help with rebasing. By the way, the database related things you have been waiting for with #135 found their way into |
Should be good. I will pick it up again. |
d6dbd6e
to
afe1636
Compare
application/src/test/java/org/togetherjava/tjbot/listener/MessageMetadataListenerTest.java
Outdated
Show resolved
Hide resolved
We seem to be having some trouble with the formatting, I think we should wait till @I-Al-Istannen and @borgrel fix it. |
afe1636
to
02dbe0a
Compare
application/src/main/java/org/togetherjava/tjbot/listener/MessageMetadataListener.java
Outdated
Show resolved
Hide resolved
/** | ||
* Listener responsible for persistence of text message metadata | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please elaborate a bit here what and when it stores.
@@ -0,0 +1,4 @@ | |||
/** | |||
* This package contains non-user interactive event listeners |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing dot .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add a link to JDAs addEventListener
thing so that people understand what its about.
private static final Pattern HELP_CHANNEL_PATTERN = Pattern.compile(".*\\Qhelp\\E.*"); | ||
|
||
private JDAUtils() {} | ||
|
||
/** | ||
* Checks if a provided channel is a help channel. | ||
* | ||
* @param textChannel provided channel. | ||
* @return true if the provided channel is a help channel, false otherwise. | ||
*/ | ||
public static boolean isAHelpChannel(TextChannel textChannel) { | ||
return HELP_CHANNEL_PATTERN.matcher(textChannel.getName()).matches(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I think it might be better to move those helpers back into where you actually use them, into TopHelperCommand
or similar.
private static long getBoundedCountAsLong(OptionMapping count) { | ||
return count == null ? MIN_COUNT : Math.min(count.getAsLong(), MAX_COUNT); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of silently accepting inputs outside of the range, I would explicitly check the range and give the user an ephemeral message back, telling them to use the command with values inside the range and stop the command.
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
}); | ||
} | ||
|
||
private static long getBoundedCountAsLong(OptionMapping count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NotNull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ll need to cross check once again but I think it comes as null when not specified. It's one of the not required fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then @Nullable
. Unless your context requires it to always exist.
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/TopHelpers.java
Outdated
Show resolved
Hide resolved
Please put everything that doesn't need to be in the application module in its own module. |
U mean the whole command should be in its own module? We havent done that so far. Or what do you specifically mean in this PR? |
02dbe0a
to
40cddc0
Compare
import org.jetbrains.annotations.Nullable; | ||
import org.jooq.Records; | ||
import org.togetherjava.tjbot.db.Database; | ||
import org.togetherjava.tjbot.util.PresentationUtils; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have not used javax.annotation
yet. I would suggest to not use them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why? Why would we prefer a vendor specific annotation and I see no point putting @NotNull/@nullable annotations across each and every method that we write.
If we prefer non-standard third party annotations, its still fine but does it have an equivalent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The annotation we are using is already in our dependencies. If you want to use this other annotation, please make sure that the dependencies cover it.
That said, for the null-checks it would probably be best to stick to one and not mix the millions of @NotNull
annotations with each other.
I dont have a strong opinion here. Maybe get other opinions (@I-Al-Istannen )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to side with Zabuzard.
Usage of @NotNull
and @Nullable
makes it clear what the arguments are.
When you look at the docs of a method, it actually shows the arguments can't be null or are nullable. (Because it displays the method signature)
If you use a class-wide annotation like this it's not shown in the docs either.
If we prefer non-standard third party annotations, its still fine but does it have an equivalent?
To my knowledge, javax annotations have been removed since Java 11, so this argument is obsolete.
import org.jetbrains.annotations.Nullable; | ||
import org.jooq.Records; | ||
import org.togetherjava.tjbot.db.Database; | ||
import org.togetherjava.tjbot.util.PresentationUtils; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to side with Zabuzard.
Usage of @NotNull
and @Nullable
makes it clear what the arguments are.
When you look at the docs of a method, it actually shows the arguments can't be null or are nullable. (Because it displays the method signature)
If you use a class-wide annotation like this it's not shown in the docs either.
If we prefer non-standard third party annotations, its still fine but does it have an equivalent?
To my knowledge, javax annotations have been removed since Java 11, so this argument is obsolete.
|
||
public final class TopHelpers extends SlashCommandAdapter { | ||
|
||
private static final String COUNT_OPTION = "count"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zabuzard is also referring to the variable's name if I understand it correctly
public final class PresentationUtils { | ||
private PresentationUtils() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He said "or"
So, why did you ignore his second statement?
private static final long MIN_COUNT = 10L; | ||
private static final long MAX_COUNT = 30L; | ||
|
||
private record TopHelperRow(Integer serialId, Long userId, Long messageCount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use the primitives instead
@d3vel0per How is it going? Still planning on finishing this? Otherwise, should we maybe assign it to someone else to help out? (no hurry though) |
Seems @d3vel0per is a bit busy right now (which is totally fair). Unassigned. Someone else can take over, if wanted 👍 |
Since origin branch of this PR is on a fork, people cannot work on it. Moved to #282. Thanks, @d3vel0per ❤️ |
Fixes #65