-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Discover] Fix csv export with relative time filter from discover main view #123206
[Discover] Fix csv export with relative time filter from discover main view #123206
Conversation
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
@elasticmachine merge upstream |
const absoluteFilter = data.query.timefilter.timefilter.createFilter(index); | ||
const timeFilter = absoluteTime | ||
? data.query.timefilter.timefilter.createFilter(index) | ||
? absoluteFilter | ||
: data.query.timefilter.timefilter.createRelativeFilter(index); | ||
|
||
// remove timeFilter from existing filter | ||
if (Array.isArray(existingFilter)) { | ||
existingFilter = existingFilter.filter( | ||
(current) => !isEqualFilters(current, absoluteFilter) | ||
); | ||
} else if (isEqualFilters(existingFilter, absoluteFilter)) { | ||
existingFilter = undefined; | ||
} | ||
|
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.
a first thought about this ... now is converted to absolute time when creating a filter, are we sure the generated time here matches to the existing time of the existing filter, which might also be converted, but it was converted before the creation of absoluteFilter
. I'm not 100% sure here how this works, so I'd need to dive a bit deeper then I can this week. in any case we'd need test coverage for this.
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.
@kertal it does look like there could be a race condition.
This is quite tricky to reason about -- I agree tests for the different cases would be really useful (even as a way to document all this!). AFAICT there are 2 scenarios we want to handle:
- Share data is requested for immediate use (e.g. CSV of exactly now)
- Share data is requested for deferred use (e.g. CSV whenever + rolling window)
In case 1 we want a search source containing an absolute time range so that we can give the user an accurate picture of their data in that moment.
In case 2 we want to give users a "rolling window" so they can get their data over time (unless they've explicitly set an absolute time filter, then RIP relative time filter).
A complication is in both cases there could be cascading time range filters, themselves either relative or absolute 🤪
therefore I think this code should try to "only" concern itself with the 2 scenarios AND not overriding existing filters. broadly something like:
if (absoluteTime === true) {
// we want to generate a search source that will generate a picture of the data now
// append the absolute time filter
} else {
// we want to generate a search source that will provide a rolling window
// append the relative time filter
}
What do you guys think?
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.
Ah, one piece I missed is "extracting" the current time range filter in Discover because we are converting to either relative or absolute, so some overriding is required 🤔 are these perhaps not separated by SearchSource.getParent
?
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.
Alright, I think we agree then we should improve code here, but since we also need to backport I'd suggest to keep the scope small, just suggested a way we can be sure that there are no race conditions. If this is fine, it would fix the issue, and we could think about improving stuff in a future PR targeting simplification in this area. How does that sound
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
LGTM
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @dmitriynj |
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.
LGTM, thx for the fix and the functional coverage 👍
…n view (#123206) * [Discover] fix relative time filter for csv export from discover main page * [Discover] fix array assignment * [Discover] fix functional test * [Discover] add test coverage for the issue * [Discover] add debug points for functional test * [Discover] try to get clipboard permissions * [Discover] fix functional test * [Discover] apply suggestion * [Discover] apply suggestion * [Discover] apply naming suggestion Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit deb7099)
💔 Some backports could not be created
Manual backportTo create the backport manually run:
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…n view (#123206) (#127847) * [Discover] fix relative time filter for csv export from discover main page * [Discover] fix array assignment * [Discover] fix functional test * [Discover] add test coverage for the issue * [Discover] add debug points for functional test * [Discover] try to get clipboard permissions * [Discover] fix functional test * [Discover] apply suggestion * [Discover] apply suggestion * [Discover] apply naming suggestion Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit deb7099) Co-authored-by: Dmitry Tomashevich <39378793+Dmitriynj@users.noreply.github.com>
…n view (elastic#123206) * [Discover] fix relative time filter for csv export from discover main page * [Discover] fix array assignment * [Discover] fix functional test * [Discover] add test coverage for the issue * [Discover] add debug points for functional test * [Discover] try to get clipboard permissions * [Discover] fix functional test * [Discover] apply suggestion * [Discover] apply suggestion * [Discover] apply naming suggestion Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…n view (elastic#123206) * [Discover] fix relative time filter for csv export from discover main page * [Discover] fix array assignment * [Discover] fix functional test * [Discover] add test coverage for the issue * [Discover] add debug points for functional test * [Discover] try to get clipboard permissions * [Discover] fix functional test * [Discover] apply suggestion * [Discover] apply suggestion * [Discover] apply naming suggestion Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit deb7099) # Conflicts: # src/plugins/discover/public/application/apps/main/utils/get_sharing_data.ts # x-pack/test/functional/apps/discover/reporting.ts
…n view (elastic#123206) * [Discover] fix relative time filter for csv export from discover main page * [Discover] fix array assignment * [Discover] fix functional test * [Discover] add test coverage for the issue * [Discover] add debug points for functional test * [Discover] try to get clipboard permissions * [Discover] fix functional test * [Discover] apply suggestion * [Discover] apply suggestion * [Discover] apply naming suggestion Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit deb7099) # Conflicts: # src/plugins/discover/public/application/apps/main/utils/get_sharing_data.ts
…n view (#123206) (#133506) * [Discover] fix relative time filter for csv export from discover main page * [Discover] fix array assignment * [Discover] fix functional test * [Discover] add test coverage for the issue * [Discover] add debug points for functional test * [Discover] try to get clipboard permissions * [Discover] fix functional test * [Discover] apply suggestion * [Discover] apply suggestion * [Discover] apply naming suggestion Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit deb7099) # Conflicts: # src/plugins/discover/public/application/apps/main/utils/get_sharing_data.ts # x-pack/test/functional/apps/discover/reporting.ts Co-authored-by: Dmitry Tomashevich <39378793+Dmitriynj@users.noreply.github.com>
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
Summary
Fixes #122575
This PR redundant absolute filter from
csv export
generated from discover main view.Test notes
(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-24h%2Fh,to:now))&_a=(columns:!(),filters:!(),index:'10881820-3b02-11eb-a646-7340c405390d',interval:auto,query:(language:kuery,query:''),sort:!(!(timestamp,desc)))
)(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-24h%2Fh,to:now))&_a=(columns:!(),filters:!(),grid:(),hideChart:!f,index:'10881820-3b02-11eb-a646-7340c405390d',interval:auto,query:(language:kuery,query:''),sort:!(!(timestamp,desc)))
query:(range:(timestamp:(format:strict_date_optional_time,gte:now-24h/h,lte:now))))