Add dateHistogramInterval utility#39091
Conversation
💔 Build Failed |
|
Jenkins, test this - short CI outage |
💚 Build Succeeded |
|
Pinging @elastic/kibana-app |
|
Pinging @elastic/kibana-app-arch |
|
cc @emmacunningham FYI (replacement of discover chart) |
flash1293
left a comment
There was a problem hiding this comment.
Code LGTM. Is there a specific reason to re-export this under static and common? Will this be a convention in NP?
| ], | ||
| moduleNameMapper: { | ||
| '^plugins/([^\/.]*)/(.*)': '<rootDir>/src/legacy/core_plugins/$1/public/$2', | ||
| '^plugins/([^\/.]*)(.*)': '<rootDir>/src/legacy/core_plugins/$1/public$2', |
There was a problem hiding this comment.
context is to allow nested folders?
There was a problem hiding this comment.
rather the opposite, to allow importing from the plugin directly, like plugin/data, but to be honest that's not needed anymore so I can actually revert that change here.
There was a problem hiding this comment.
Well but since we might hit that problem another time I might just leave it, since you anyway already approved it :)
💚 Build Succeeded |
💚 Build Succeeded |
💚 Build Succeeded |
lukeelmers
left a comment
There was a problem hiding this comment.
Just one last question :)
| */ | ||
|
|
||
| import { parseInterval } from '../utils/parse_interval'; | ||
| import { isValidEsInterval } from '../../../core_plugins/data/common'; |
There was a problem hiding this comment.
Are you importing from data/common here instead of data/public to avoid the mocking issues that were surfacing due to all of the stuff that's imported into data/public/index?
Because otherwise I'd suggest importing from data/public since common will be an implementation detail of the plugin in the new platform, and may change.
There was a problem hiding this comment.
Yes that was exactly the fix (that I didn't remember in our last meeting). So basically because of the mocking issues I import directly from common. I also added to the PR description that this is a tech-debt we need to remove later on, once we have a proper solution for the mocking issue with one large entry file (or then potentially another solution).
cc @skaapgif @joshdover This was actually the workaround I used for now, which I forgot about in our last meeting, how I fixed it in this PR :) So simply deep importing from not the top level entry file.
* Add dateHistogramInterval utility * Fix editor bug * Fix tests * FIx imports to temporary solution * Remove wrongly merged translations * Remove old static.ts file
💚 Build Succeeded |
Summary
Adds the
dateHistogramIntervalutility, which can be used to calculate the correct interval key (calendar_intervalorfixed_interval) for a given interval string (like10s,1h, etc.).The return will be an object that can simply spreaded into a
date_histogrambody. So you should replace your previousintervalkey by a call to that function:This function will throw an error if the interval itself is not a valid Elasticsearch interval (like
2w,5.0h, ...). Please make sure if you use it for user input, that the user input is properly validated beforehand and you show the user a meaningful error message. You can use theisValidEsIntervalfunction as follows:Release Summary: Migrate date_histograms to the new calendar_interval/fixed_interval. Solves some deprecation warnings in Kibana.
For reviewers
This PR adds a bit of tech-debt, since we import directly from the
plugins/data/commonfolder (which is not one of the root folders we should import later on). Unfortunately there are still a couple of unsolved issues around testing and NP plugins, why we decided to for now introduce that tech-debt, especially since it's really easy to change those imports later on.This PR also makes use of this method in courier via AggConfig and also makes sure the editor properly validates that value beforehand.
There are a lot of test fixes, now that the AggConfig actually needs a valid interval since it would otherwise throw an exception.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately[ ] This includes a feature addition or change that requires a release note and was labeled appropriately