-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implementation of a Command printing the release time of a build #47
base: master
Are you sure you want to change the base?
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.
I think this is a good idea but why not just add that to the changelog
command and add some aliases like !build
(if it doesn't exist already). That way you have everything in one place.
...src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/DateVersionCommand.java
Show resolved
Hide resolved
...src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/DateVersionCommand.java
Outdated
Show resolved
Hide resolved
...src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/DateVersionCommand.java
Outdated
Show resolved
Hide resolved
...src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/DateVersionCommand.java
Outdated
Show resolved
Hide resolved
Didn't see your comment before, sry.
Don't know if you saw it but Alpaca kind of requested that, I just executed it (Link to Discord Chat). :D Actually I see this more like of a fun command where the changelog command is a serious one. If you really want I can do it like that but I don't think it's a good idea, the changelog already has a lot of contents and too many information aren't good imo. |
Added Logging for Exception occurrences, simplified getting a formatted time based of a OffsetDateTime and removed command name from List of Aliases
I wasn't home over the weekend and didn't want to commit without your response so I did it now, sorry for any inconveniences. |
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.
Just a minor issue with using SLF4J incorrectly
...src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/DateVersionCommand.java
Outdated
Show resolved
Hide resolved
...src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/DateVersionCommand.java
Outdated
Show resolved
Hide resolved
I'm just gonna let someone else (maybe Mighty) look over it before merging |
Yeah, that's fine. :) |
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 suggested the command so you can show people how ancient their JDA versions are more easily. That said I also like @kantenkugel's idea to add it to the changelog
command, although the focus there isn't on the date anymore. It can always be added to that command additionally.
|
||
public class DateVersionCommand extends Command | ||
{ | ||
private static final String DATE_FORMAT = "yyyy-MM-dd; HH:mm:ss"; |
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.
Would be nice to include the timezone here as the time is kinda useless without it
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.
That reminds me... I think i added the DurationUtils i wrote to Butler... Which means we could print the difference version-release -> now in some 1w, 3d, ... format as well (next to datetime).
Possibly needs to be expanded with month/year handling cuz i don't think i did those
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.
@Almighty-Alpaca Which Timezone should I use then? Or do you mean I should just add O
to the Pattern?
@kantenkugel Can you explain the includeIntermed
param of the formatDuration
function? I saw no difference when trying out both.
Currently it looks like this:
But this doesn't look very good to me. Any suggestions or are you fine with that?
That said I also like @kantenkugel's idea to add it to the
changelog
command
Should I add it to the Changelog Command as well or should this be handled in another PR?
Edit:
Possibly needs to be expanded with month/year handling cuz i don't think i did those
Yes, you would. Only milliseconds to days are in the formatDuration
function (so even the week one is missing).
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 includeIntermed
parameter determines what happens to 0-values... with includeIntermed
set to true
, 10h 0m 0s
is possible. With includeIntermed
set to false
, it would just print 10h
. 0s
is only printed if no other value is >0
For this command, i would just include them... most of the time you won't have any 0-values anyway, so might as well go with all fields provided every time anyway.
For the changelog command, i would not add the duration btw. the datetime is enough there (timestamp of build)
For timezone, i would probably go with UTC.
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.
Agree with Kant about UTC.
Looking at the last screenshot though I think it would be kinda cool to make it more text like, for example:
Version 3.8.3_464 was released on 22/06/2019 at 18:08 (GMT)
That was approximately 4 Days, 3 Hours and 32 Minutes ago.
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.
Sure, mine was only an idea. You don't have to do it exactly like that.
Well normally I expect that the devs have the last word on how they want the code to be and not the people requesting their code to be merged. :D
Would I be allowed to make it public?
Any info on that? Then I can commit it real quick before going to bed and you can do further code checks. :D
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 have never touched that piece of code but I don't see any reason why you could make it public
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.
Alright, then I will make a copy and don't make it public.
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.
*couldn't, I meant I don't see any reason why you couldn't make it public, sry
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.
No worries, I already thought that, that's why I actually posted that comment. :D
And even if I would have used a copy, another commit and it's fixed so no worries. :)
Will be committed in the next 5 minutes.
…updated the Format of the printed DateTime Also added the Build Time to the ChangelogCommand and refactored the code a bit
{ | ||
final JenkinsBuild build = args == null | ||
? JENKINS.getLastSuccessfulBuild() | ||
: JENKINS.getBuild(Integer.parseInt(args[0])); |
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 believe I made a tiny mistake here. Shouldn't args[0]
not be the item name according to line 45?
I mean VersionedItem#getChangelogProvider
always returns null
at the moment so it will always stop executing with "No Changelogs set up for " + item.getName()
(line 57) but if this is gonna be changed, this will "crash" (the NumberFormatException
will be catched) when providing another Item since args[0]
isn't a build number / an integer in that case.
I would fix that by replacing args[0]
with args[args.length - 1]
.
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.
@kantenkugel I talked already with Alpaca in the JDA Server about this today, he has problems with the general code base right now so it would be great if you can also look over it (and maybe you can give me some response on that one too). However, it "sounds plausible" for Alpaca and it's ready to be merged (after I updated the code based on my last review).
public static final JenkinsApi JENKINS = JenkinsApi.JDA_JENKINS; | ||
public static final DateTimeFormatter FORMATTER = getDateTimeFormatter(); | ||
|
||
public static DateTimeFormatter getDateTimeFormatter() { |
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 {
should be in the next line to match the general code style.
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.
JDA-Butler/bot/src/main/java/com/almightyalpaca/discord/jdabutler/util/DateUtils.java
Lines 17 to 26 in 6099bc7
try | |
{ | |
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " (z)"); | |
} | |
catch (NullPointerException | IllegalArgumentException ex) | |
{ | |
final String defaultFormat = "dd.MM.yyyy 'at' HH:mm:ss (z)"; | |
Bot.LOG.warn("Given format for DateVersionCommand was not valid, using: " + defaultFormat); | |
formatter = DateTimeFormatter.ofPattern(defaultFormat); | |
} |
Maybe DateTimeFormatter.ofPattern
should be called only once, doing the try-catch with a String (the pattern).
Edit:
Okay, don't know what I was thinking when commenting that. Adding (z)
twice looked kinda ugly so I thought this could be made better, also then only one DateTimeFormatter.ofPattern
would be needed but since there is no method to check if a pattern is valid, the try-catch is required. Or do you know how this can be done better?
Description
This PR adds a command telling when a JDA build was released.
If no version was provided, the latest successful build will be used instead.
Potential Errors like parsing the User Input and
IOException
ofJenkinsApi#getBuild
are correctly handled.Used Code Style was respected.
Example Preview