-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Lens] Bind all time fields to the time picker #63874
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
Conversation
| partialRows: boolean; | ||
| includeFormatHints: boolean; | ||
| aggConfigs: string; | ||
| timeField?: string[]; |
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.
remove ?
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.
The parameter is not defined is required in the definition below, so it can be skipped and thus can be undefined. Actually the typing of the other parameters here is wrong, because they should also all have ? or being marked as required: true in their definition, but I didn't want to fix this in this PR.
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.
so we have timeField and timeFields ?
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.
Actually the typing of the other parameters here is wrong, because they should also all have
?or being marked asrequired: truein their definition, but I didn't want to fix this in this PR.
@timroes This actually highlights weird thing about the Expression function typings which I don't think we have been doing consistently:
The types are what get enforced inside the function body. So while any arg with default: 'whatever' set is technically optional for users of the expression function, once you are inside the expression function itself, if it is not marked with ? in the arguments interface, TS will warn that the arg can be possibly undefined (since TS doesn't know that the defaults get injected at runtime).
So which is right? Do we write the typings to be accurate for the users of the functions (which means lots of ?), at the expense of function authors needing a lot of unnecessary if (args.whatever) checks, or args.whatever! ... Or do we write the typings to be accurate for the function authors, at the expense of users of the functions not having accurate typings?
IMO your proposed approach is probably better (include ? if there's a default or no required: true). It just means needing to update many of our function definitions (including Canvas functions which seem to have this discrepancy as well).
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.
^ Thinking about this more, in ExpressionFunctionDefinition we might be able to enforce the presence of required: true for non-optional args.
At any rate; that's a topic for a different thread 🙂
| import { AggGroupNames } from '../aggs'; | ||
| import moment from 'moment'; | ||
|
|
||
| interface Bucket { |
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.
defining an interface in tests ?
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.
The previous definition is any and I just didn't want to continue using any below. I could have also inlined this type, but since I used it in multiple places just defined it as an interface on top.
ppisljar
left a comment
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.
looked at it quickly and seems good
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
lizozom
left a comment
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.
Added a few comment
| import { getSearchService, getQueryService, getIndexPatterns } from '../../services'; | ||
| import { buildTabularInspectorData } from './build_tabular_inspector_data'; | ||
| import { getRequestInspectorStats, getResponseInspectorStats, serializeAggConfig } from './utils'; | ||
| import { calculateBounds, getTimeForField } from '../../query/timefilter/get_time'; |
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.
//nit
Should be exported from ../../query
| timeFields && timeFields.length > 0 | ||
| ? timeFields | ||
| : [ | ||
| indexPattern?.fields.find(field => field.name === indexPattern.timeFieldName)?.name, |
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.
indexPattern.getTimeField
| return getTime(searchSource.getField('index'), timeRange); | ||
| return allTimeFields | ||
| .map(fieldName => getTimeForField(indexPattern, timeRange, fieldName)) | ||
| .filter((rangeFilter): rangeFilter is RangeFilter => Boolean(rangeFilter)); |
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.
//nit
Maybe simplify with isRangeFilter?
| return createTimeRangeFilter(indexPattern, timeRange, field); | ||
| } | ||
|
|
||
| export function getTime( |
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.
getTimeFilter \ getTimeFilterDefault :)
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.
++ The naming getTime and getTimeFilter is a bit unclear.
another nit - It would also be nice to maybe add an explanatory comment to each of the functions here.
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.
Just took a harder look at this, thanks for the prodding to do this. The naming confusion was because both functions were basically 90% similar code with one extra input, so I've condensed these into the same function with an options argument instead of positional arguments.
| doc_count: esResponse.hits.total, | ||
| }; | ||
|
|
||
| let timeRange: TabbedRangeFilterParams | 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.
yay
|
@elasticmachine merge upstream |
ppisljar
left a comment
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.
code LGTM
|
Tested in Lens in commit "Add full migration"
|
|
Fixed the bug in both the Lens migration and the unmigrated Lens expression. It turns out that |
… timeField=\"products.created_on\"}
mbondyra
left a comment
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.
tested locally, LGTM 🆗
ppisljar
left a comment
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.
code LGTM
| return createTimeRangeFilter(indexPattern, timeRange, field); | ||
| } | ||
|
|
||
| export function getTime( |
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.
++ The naming getTime and getTimeFilter is a bit unclear.
another nit - It would also be nice to maybe add an explanatory comment to each of the functions here.
| type Output = Promise<KibanaDatatable>; | ||
|
|
||
| interface Arguments { | ||
| export interface Arguments { |
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.
Why does this need to be exported now? (I might have missed it)
|
I think I've resolved all of the naming comments that I could find. Thanks for bringing them up- @lukeelmers @lizozom if you want to review again, feel free. |
lukeelmers
left a comment
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.
Thanks @wylieconlon, I think those changes make things much clearer!
Otherwise, the code here LGTM (I only reviewed updates to the data plugin).
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Bind non primary time fields to timepicker * Fix typescript argument types * Allow auto interval on all fields * Remove lens_auto_date function * Fix existing jest tests and add test todos * Remove lens_auto_date from esarchives * Add TimeBuckets jest tests * Fix typo in esarchiver * Address review feedback * Make code a bit better readable * Fix default time field retrieval * Fix TS errors * Add esaggs interpreter tests * Change public API doc of data plugin * Add toExpression tests for index pattern datasource * Add migration stub * Add full migration * Fix naming inconsistency in esaggs * Fix naming issue * Revert archives to un-migrated version * Ignore expressions that are already migrated * test: remove extra spaces and timeField=\\"products.created_on\\"} to timeField=\"products.created_on\"} * Rename all timeField -> timeFields * Combine duplicate functions * Fix boolean error and add test for it * Commit API changes Co-authored-by: Wylie Conlon <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Marta Bondyra <[email protected]>
* master: (42 commits) [Ingest] Allow aggent to send metadata compliant with ECS (elastic#64452) [Endpoint] Remove todos, urls to issues (elastic#64833) [Uptime] Remove hard coded value for monitor states histograms (elastic#64396) Feature/send feedback link (elastic#64845) [ML] Moving get filters capability to admin (elastic#64879) Remove edit alert button from alerts list (elastic#64643) [EPM] Handle constant_keyword type in KB index patterns and ES index templates (elastic#64876) [ML] Disable data frame anaylics clone button based on permission (elastic#64830) Dashboard url generator to preserve saved filters from destination dashboard (elastic#64767) add generic typings for SavedObjectMigrationFn (elastic#63943) Allow to define and update a defaultPath for applications (elastic#64498) [Event Log] add rel=primary to saved objects for query targets (elastic#64615) [Lens] Use a size of 5 for first string field in visualization (elastic#64726) [SIEM][Lists] Removes plugin dependencies, adds more unit tests, fixes more TypeScript types [Ingest] Edit datasource UI (elastic#64727) [Lens] Bind all time fields to the time picker (elastic#63874) [Lens] Use suggestion system in chart switcher for subtypes (elastic#64613) Improve alpha messaging (elastic#64692) [Ingest] Allow to enable monitoring of elastic agent (elastic#63598) [Metrics UI] Fix alerting when a filter query is present (elastic#64575) ...
* [Lens] Bind all time fields to the time picker (#63874) * Bind non primary time fields to timepicker * Fix typescript argument types * Allow auto interval on all fields * Remove lens_auto_date function * Fix existing jest tests and add test todos * Remove lens_auto_date from esarchives * Add TimeBuckets jest tests * Fix typo in esarchiver * Address review feedback * Make code a bit better readable * Fix default time field retrieval * Fix TS errors * Add esaggs interpreter tests * Change public API doc of data plugin * Add toExpression tests for index pattern datasource * Add migration stub * Add full migration * Fix naming inconsistency in esaggs * Fix naming issue * Revert archives to un-migrated version * Ignore expressions that are already migrated * test: remove extra spaces and timeField=\\"products.created_on\\"} to timeField=\"products.created_on\"} * Rename all timeField -> timeFields * Combine duplicate functions * Fix boolean error and add test for it * Commit API changes Co-authored-by: Wylie Conlon <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Marta Bondyra <[email protected]> * fix: fix migration * types fix Co-authored-by: Tim Roes <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Marta Bondyra <[email protected]>
…bana into pipeline-editor-part-mvp-2 * 'feature/ingest-node-pipelines' of github.com:elastic/kibana: (90 commits) remove unused import address review feedback [Ingest pipelines] Cleanup (elastic#64794) [Ingest] Edit datasource UI (elastic#64727) [Lens] Bind all time fields to the time picker (elastic#63874) [Lens] Use suggestion system in chart switcher for subtypes (elastic#64613) Improve alpha messaging (elastic#64692) [Ingest] Allow to enable monitoring of elastic agent (elastic#63598) [Metrics UI] Fix alerting when a filter query is present (elastic#64575) skip flaky suite (elastic#64812) (elastic#64723) [Maps] do not display EMS or kibana layer wizards when not configured (elastic#64554) [Reporting/Test] Convert functional test code to Typescript (elastic#64601) make inserting timestamp with navigate methods optional with default true (elastic#64655) [EPM] Update UI to handle package versions and updates (elastic#64689) Minimize dependencies required by our telemetry middleware (elastic#64665) [Telemetry] oss api tests (elastic#64602) [ML] Adding endpoint capability checks (elastic#64662) Update jest config for coverage (elastic#64648) [SIEM][NP] Fixes bug in ML signals promotion (elastic#64720) share single data plugin bundle (elastic#64549) ...
This changes
esaggsand Lens to support auto date histograms on any time field the user wants:Fixes #63868
TODO:
Checklist