-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement Relative Time for Outage Start and End Dates #78
base: main
Are you sure you want to change the base?
Conversation
…esolves fedora-infra#51) This commit updates the help text for the user info and user hello commands within the FasHandler class. The descriptions are modified to accurately reflect the information provided by each command: user info: Returns detailed information about a Fedora user, including username, human name, pronouns, creation date, timezone, locale, and GPG key IDs. user hello: Returns a brief introduction of a Fedora user, including username, human name, and pronouns (if available). This clarifies the distinction between the commands and improves the user experience when interacting with the bot. Signed-off-by: [KimFarida] <[[email protected]]>
@abompard @ryanlerch Hi! Could you please take a look |
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 would recommend a few adjustments, but this is a great start!
) | ||
message += f"**no planned or ongoing outages on Fedora Infrastructure.**{NL}" | ||
await evt.respond(message) | ||
return |
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.
Nice ✨
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.
Nice ✨
Thank you !
fedora/infra.py
Outdated
) | ||
|
||
message += f" * {format_title(outage)}{NL}" | ||
message += f" Started : {relative_start_time}{NL}{start_time}" |
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 assume the {NL}
means "newline"?
Perhaps formatting it so it reads Started: 2024-04-01-11:30:38 (3 minutes ago)
would be clearer.
fedora/infra.py
Outdated
relative_start_time = self.get_relative_time(start_time - now) | ||
|
||
message += ( | ||
f" Scheduled to start :" + f"{start_time}" + f"{relative_start_time}{NL}" |
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.
f" Scheduled to start :" + f"{start_time}" + f"{relative_start_time}{NL}" | |
f" Scheduled to start: {start_time} ({relative_start_time}){NL}" |
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.
Done!
message += ( | ||
f" Estimated to end: " | ||
f"{outage.get('enddate') if outage.get('enddate') else 'Unknown'}{NL}" | ||
f"{self.get_relative_time(outage.get('enddate') - now if outage.get('enddate') else datetime.datetime.max - now)}{NL}" |
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.
Today I learned about datetime.datetime.max
date_string = datetime.datetime.strptime(date_string, date_format) | ||
return date_string | ||
|
||
def get_relative_time(self, delta): |
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.
It looks like the project already has a dependency on the arrow
library, which provides a humanize call to calculate relative times. I'd recommend using that instead of implementing it yourself (although your implementation looks nice and simple!)
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.
It looks like the project already has a dependency on the
arrow
library, which provides a humanize call to calculate relative times. I'd recommend using that instead of implementing it yourself (although your implementation looks nice and simple!)
inserts crying emoji I knew there was something i could use but the DSA warrior in me said no. It took a while to come up with the logic hahah. Thank you for the review!
@@ -31,8 +32,8 @@ | |||
"outages", | |||
[ | |||
( | |||
[OUTAGE_FULL, OUTAGE_NO_ENDDATE, OUTAGE_NO_ENDDATE_NO_TICKET, OUTAGE_NO_TICKET], | |||
[OUTAGE_FULL, OUTAGE_NO_ENDDATE, OUTAGE_NO_ENDDATE_NO_TICKET, OUTAGE_NO_TICKET], | |||
[OUTAGE_FULL, OUTAGE_NO_ENDDATE, OUTAGE_NO_TICKET, OUTAGE_NO_ENDDATE_NO_TICKET], |
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.
Was there a reason to re-order things here? If it's just for style reasons I'd recommend to leave the change out and submit it as a separate PR so it's clear why the change occurred.
"##### Ongoing\n" | ||
"● **thetitle (https://i.test/1)**\n" | ||
" Started at: 2023-08-06T1:00:00+0000\n" | ||
" Estimated to end: 2023-08-06T2:00:00+0000\n" |
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.
Will this test pass now that it should include relative times?
A library I've used in the past is https://pypi.org/project/freezegun/ to set a stable time to make it easier to write tests that do time calculations off the current time, in case that's why this doesn't include relative time changes.
Title: Implement Relative Time for Outage Start and End Dates
Description:
This pull request introduces the following improvements to the
infra_status
command:date_validation
andget_relative_time
, are added to enhance code organization and maintainability.pytest.mark.xfail
in the test).Before:
After:
Testing:
Unit tests are included to verify the functionality with various outage scenarios (provided in the code section).
Additional Notes:
This PR incorporates the code formatting changes (Black) and corrected docstrings mentioned in the previous commits.
I welcome your feedback and look forward to merging this PR!