-
Notifications
You must be signed in to change notification settings - Fork 366
use ET timezone consistently in the admin UI #693
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -305,4 +305,26 @@ def test_filter_options | |||||
| "is not null", | ||||||
| ] | ||||||
| end | ||||||
|
|
||||||
| def test_table_displays_time_in_eastern_timezone | ||||||
| FactoryBot.create(:log_item, :request_at => Time.parse("2015-01-16T06:06:28.816Z").utc, :request_method => "OPTIONS") | ||||||
| LogItem.refresh_indices! | ||||||
|
|
||||||
| admin_login | ||||||
| visit "/admin/#/stats/logs?search=&start_at=2015-01-12&end_at=2015-01-18&interval=day" | ||||||
| refute_selector(".busy-blocker") | ||||||
|
|
||||||
| assert_text("2015-01-16 01:06:28 EST") | ||||||
| end | ||||||
|
|
||||||
| def test_table_displays_time_in_eastern_timezone_during_dst | ||||||
| FactoryBot.create(:log_item, :request_at => Time.parse("2015-07-16T06:06:28.816Z").utc, :request_method => "OPTIONS") | ||||||
| LogItem.refresh_indices! | ||||||
|
|
||||||
| admin_login | ||||||
| visit "/admin/#/stats/logs?search=&start_at=2015-07-12&end_at=2015-07-18&interval=day" | ||||||
| refute_selector(".busy-blocker") | ||||||
|
|
||||||
| assert_text("2015-07-16 02:06:28 EDT") | ||||||
| end | ||||||
|
||||||
| analytics: | |
| timezone: America/Denver |
So if you start leveraging that setting, I think you'll need to update these tests to use MDT/MST for their frame of reference. There's technically ways you could also change the timezone in specific tests, but I think that's probably overkill here, so I think just updating these tests to verify the mountain time assumption is sufficient.
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.
Yep, I updated the tests to use MDT
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -226,4 +226,26 @@ def test_no_results_non_existent_indices | |||||||||||||||||||||||||||||
| "recordsTotal" => 0, | ||||||||||||||||||||||||||||||
| }, data) | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def test_csv_timestamps_in_iso8601_utc_format | ||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test looks good, but there's one other semi-related test that's failing now: https://github.com/NatLabRockies/api-umbrella/actions/runs/21634777879/job/62359925312#step:5:385 api-umbrella/test/apis/admin/stats/test_users.rb Lines 99 to 112 in 1cb2bd5
I think you'll need to update those tests to call
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thank you! I was trying to figure out what I was missing on these failures. Fixed! |
||||||||||||||||||||||||||||||
| FactoryBot.create(:log_item, :request_at => Time.parse("2015-01-16T06:06:28.816Z").utc, :request_user_agent => unique_test_id) | ||||||||||||||||||||||||||||||
| LogItem.refresh_indices! | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| response = Typhoeus.get("https://127.0.0.1:9081/admin/stats/logs.csv", http_options.deep_merge(admin_session).deep_merge({ | ||||||||||||||||||||||||||||||
| :params => { | ||||||||||||||||||||||||||||||
| "start_at" => "2015-01-13", | ||||||||||||||||||||||||||||||
| "end_at" => "2015-01-18", | ||||||||||||||||||||||||||||||
| "interval" => "day", | ||||||||||||||||||||||||||||||
| "start" => "0", | ||||||||||||||||||||||||||||||
| "length" => "10", | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| })) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| assert_response_code(200, response) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| csv = CSV.parse(response.body) | ||||||||||||||||||||||||||||||
| assert_equal(2, csv.length) | ||||||||||||||||||||||||||||||
| assert_equal("Time", csv[0][0]) | ||||||||||||||||||||||||||||||
| assert_equal("2015-01-16T06:06:28.816Z", csv[1][0]) | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
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.
There's a system-wide
analytics.timezoneconfiguration setting that is used throughout the system to determine this type of default time zone to be used. This system setting is exposed during the login in some session data, and that's how the charts know what time zone to use:api-umbrella/src/api-umbrella/admin-ui/app/routes/stats/base.js
Line 26 in 1cb2bd5
So to remain consistent with this configuration setting, I'd maybe recommend using that same setting here instead of hard-coding it to ET (even though for the api.data.gov deploy, it's hard-coded to ET):
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.
Oh I didn't spot this, cool! Changed to utilize. Since there's no
this.sessioncontext here I had to refactor some things, and change howrenderTimeis structured. Used the same pattern implemented in other functions likerenderLinkedListhere indata-tables-helpers.js, but then had to adapt call locations to use the new method signature. I didn't go with a plainoptionsbut just set things up to explicitly require passing inthis.session.data.authenticated.analytics_timezonewhen callingrenderTime. This required touching a number of other files including injectingsessioninto relevantresults-table.js's. If you think there's a cleaner way let me know!