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

feat(custom-timerange-tz): timeZone dropdown is now integrated in setting custom time ranges for queries #17992

Merged
merged 15 commits into from
May 7, 2020

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented May 7, 2020

Closes #17877

Purpose

The primary purpose of this PR is to ensure that whenever a user sets UTC as their timeZone and is querying a custom timeRange, their query will query data that was set at that set time in UTC (not the adjusted locale -> UTC time).

Problem

The UI for the timeZone (local or UTC) was often confusing and seemed to indicate functionality beyond displaying graphs in UTC.

Solution

Created a selector to update the timeRange whenever a query is executed with a custom timeRange and the timeZone set to UTC.

@asalem1 asalem1 requested a review from hoorayimhelping May 7, 2020 13:38
ui/src/dashboards/selectors/index.ts Outdated Show resolved Hide resolved
ui/src/dashboards/selectors/index.ts Show resolved Hide resolved
ui/src/dashboards/selectors/index.ts Outdated Show resolved Hide resolved
ui/src/dashboards/selectors/index.ts Outdated Show resolved Hide resolved
expect(
untypedGetTimeRangeWithTimeZone({ranges, currentDashboard, app})
).toEqual(expected)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

these tests look fine, and are wise in that they don't reference like today or now but instead solid dates in the past.

but having said that, a career of having tests around checking date/times that fail randomly has made me extremely wary and gunshy of them. just keep an eye on tests that involve dates and time. they can fail and blow up in weird and unexpected and painful ways.

@@ -164,7 +164,7 @@ const mstp = (state: AppState): StateProps => {
const fillColumns = getFillColumnsSelection(state)
const symbolColumns = getSymbolColumnsSelection(state)

const timeZone = state.app.persisted.timeZone
const timeZone = getTimeZone(state)
Copy link
Contributor

Choose a reason for hiding this comment

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

so the line this is replacing wouldn't set the timeZone to local if it state.app.persisted.timeZone didn't exist. this function will. is that okay for this component? i imagine it is, but just want to be explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also noticed that. It's weird because we set local as the default in only one place, but I think it's good to have a default for this value, especially if it's a required property. I'm very wary of assigning defaultProps, but in this case I think it's safe to assign a default even if none were specified

@asalem1 asalem1 requested a review from hoorayimhelping May 7, 2020 20:09
@ayang64 ayang64 mentioned this pull request May 7, 2020
5 tasks
Copy link
Contributor

@hoorayimhelping hoorayimhelping left a comment

Choose a reason for hiding this comment

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

nice work! good job iterating chasing down circleci configs.

one nit, one snarky comment about a comment.

putting this here in case we're looking at this commit in the future, maybe in the fall around DST: hello from the past!

// https://github.com/influxdata/influxdb/issues/17877
// Example: user selected 10-11:00am and sets the dropdown to UTC
// Query should run against 10-11:00am UTC rather than querying
// 10-11:00am local time (offset depending on timezone)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice comment!

nit: put it above the function definition

// 10-11:00am local time (offset depending on timezone)
const offset = new Date(date).getTimezoneOffset()
if (offset > 0) {
// subtract tz minute difference
Copy link
Contributor

Choose a reason for hiding this comment

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

OH! is that what the subtract function does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

;)

@asalem1 asalem1 merged commit 97c1501 into master May 7, 2020
@asalem1 asalem1 deleted the fix/de-tz-dropdown-disconnect branch May 7, 2020 21:39
asalem1 added a commit that referenced this pull request May 7, 2020
…d in setting custom time ranges for queries (#17992)"

This reverts commit 97c1501.
asalem1 added a commit that referenced this pull request May 7, 2020
…d in setting custom time ranges for queries (#17992)" (#18008)

This reverts commit 97c1501.
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.

The UTC / Local dropdown does not work
2 participants