Skip to content
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

Update how datetime format is set and used #184

Merged
merged 4 commits into from
Sep 23, 2024
Merged

Conversation

rosswhitfield
Copy link
Member

@rosswhitfield rosswhitfield commented Sep 23, 2024

Description of the changes

Ref 7059: [WebMon] Standardize timestamp format

The datetime format should now be consistent everywhere in the web monitor. It has also been configured slightly differently to be parsable and still human readable. In order to change all the datetime formats you just need to update src/webmon_app/reporting/formats/en_US/formats.py.

By creating and using the formats module instead of setting DATETIME_FORMAT directly in the settings, datetime's will automatically be formatted by the django template engine. And we can make use of the django.utils.formats.localize.

Check all that apply:

  • updated documentation
  • Source added/refactored
  • Added unit tests
  • Added integration tests
  • (If applicable) Verified that manual tests requiring the /SNS and /HFIR filesystems pass without fail

References:

  • Links to IBM EWM items:
  • Links to related issues or pull requests:

Manual test for the reviewer

(Instructions for testing here)

Check list for the reviewer

  • best software practices
    • clearly named variables (better to be verbose in variable names)
    • code comments explaining the intent of code blocks
  • All the tests are passing
  • The documentation is up to date
  • code comments added when explaining intent

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Project coverage is 77.33%. Comparing base (6077aad) to head (1c4e10a).

Files with missing lines Patch % Lines
src/webmon_app/reporting/report/admin.py 0.00% 2 Missing ⚠️
src/webmon_app/reporting/dasmon/view_util.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #184      +/-   ##
==========================================
+ Coverage   77.25%   77.33%   +0.08%     
==========================================
  Files          50       51       +1     
  Lines        4633     4611      -22     
==========================================
- Hits         3579     3566      -13     
+ Misses       1054     1045       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@backmari backmari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about Django's format module, but this looks like the appropriate way to format datetimes. As far as I understand, the template engine should format datetime objects automatically. @rosswhitfield did you test without formats.localize - is that needed for the formatting to be applied?
I tested locally and all the views I found had the datetimes formatted consistenly according to the new format.

@rosswhitfield
Copy link
Member Author

I didn't know about Django's format module, but this looks like the appropriate way to format datetimes. As far as I understand, the template engine should format datetime objects automatically. @rosswhitfield did you test without formats.localize - is that needed for the formatting to be applied? I tested locally and all the views I found had the datetimes formatted consistenly according to the new format.

format.localize is only needed when not rendering a template, so for example get_update that returns data as json. If you return render(...) then the formatting is automatically applied.

@rosswhitfield rosswhitfield merged commit 793af07 into next Sep 23, 2024
4 checks passed
@rosswhitfield rosswhitfield deleted the datetime_format branch September 23, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants