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

fix(ui): adding times in script editor will default start and endtime for timerange queries #16201

Merged
merged 7 commits into from
Dec 12, 2019

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented Dec 11, 2019

Closes #16123

Problem

Currently, graph start and end times were being set based on selections from the dropdown regardless of whether the script editor input manual time ranges.

Solution

Before determining the start and end time, check to see whether a custom time has been input in the script editor

  • CHANGELOG.md updated with a link to the PR (not the Issue)

@asalem1 asalem1 requested review from ebb-tide and a team December 11, 2019 17:55
@ghost ghost requested review from drdelambre and removed request for a team December 11, 2019 17:55
@asalem1 asalem1 requested a review from drdelambre December 11, 2019 22:04
Copy link
Contributor

@drdelambre drdelambre left a comment

Choose a reason for hiding this comment

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

in case you find the need to extract all of the variables in a query to test existence, it looks like this: query.match(/v.\S*/g).map(m => m.slice(2))

ui/src/timeMachine/components/Vis.tsx Outdated Show resolved Hide resolved
ui/src/shared/components/HeatmapPlot.tsx Show resolved Hide resolved
ui/src/shared/components/HeatmapPlot.tsx Show resolved Hide resolved
@@ -15,7 +15,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
interface OwnProps {
view: View
check: Partial<Check>
timeRange: TimeRange
timeRange: TimeRange | null
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't look like you are using this prop

Copy link
Contributor

Choose a reason for hiding this comment

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

ah you are... but I think you should not be

ui/src/shared/utils/useVisDomainSettings.ts Outdated Show resolved Hide resolved
ui/src/shared/utils/useVisDomainSettings.ts Show resolved Hide resolved
ui/src/timeMachine/components/Vis.tsx Outdated Show resolved Hide resolved
ui/src/timeMachine/components/Vis.tsx Outdated Show resolved Hide resolved
ui/src/timeMachine/selectors/index.ts Outdated Show resolved Hide resolved

export const getActiveTimeRange = (timeRange: TimeRange, queries: array) => {
if (!queries) {
return timeRange
Copy link
Contributor

Choose a reason for hiding this comment

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

ooh interesting. I wonder if we should check for when queries.text is empty as well... ?
Would like to take a look at what happens to an empty graph with these changes.

Copy link
Contributor Author

@asalem1 asalem1 Dec 11, 2019

Choose a reason for hiding this comment

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

Hmmm, I wonder if that would ever be possible since there's a minimum criteria to submit a query that gets compiled into the script text

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you test it visually with no query before merging please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

definitely

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No query = cannot submit without some DOM manipulation (removing the disabled flag from the console)

ui/src/shared/components/cells/Cell.tsx Outdated Show resolved Hide resolved
@asalem1 asalem1 requested a review from ebb-tide December 11, 2019 23:36
ui/src/shared/components/RefreshingView.tsx Outdated Show resolved Hide resolved
const timeZone = state.app.persisted.timeZone

return {
endTime: getEndTime(timeRange),
startTime: getStartTime(timeRange),
ranges: timeRange,
Copy link
Contributor

Choose a reason for hiding this comment

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

let's keep calling this timeRange to signal to the next programmer that this is the same old timeRange that they know from the rest of the app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but we have timeRange in the OwnProps :(

Copy link
Contributor

Choose a reason for hiding this comment

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

why are we passing the same prop to the same component twice? What is the difference between them? Which one is redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference between them is that the timeRange refers to the dropdown selection while the ranges refer to the specific ranges in the query script editor

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not correct.

) => {
const range = extent((data as number[]) || [])
if (!timeRange) {
Copy link
Contributor

Choose a reason for hiding this comment

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

that might happen for a variety of reasons. we don't know what to do if timeRange is undefined.


export const getActiveTimeRange = (timeRange: TimeRange, queries: array) => {
if (!queries) {
return timeRange
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you test it visually with no query before merging please?

@asalem1 asalem1 merged commit eefb8dd into master Dec 12, 2019
ebb-tide added a commit that referenced this pull request Dec 12, 2019
… endtime for timerange queries (#16201)"

This reverts commit eefb8dd.
@asalem1 asalem1 deleted the custom-timerange branch December 12, 2019 19:13
alexpaxton pushed a commit that referenced this pull request Jan 9, 2020
… for timerange queries (#16201)

fix(ui): adding times in script editor will default start and endtime for timerange queries, compute timeranges based on script and based on widest date range & fix dashboard so that cells that have been saved with timerange scripts are based on those timeranges
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.

graph not handling time range correctly
3 participants