-
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
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) |
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. Is there a specific reason to re-export this under static
and common
? Will this be a convention in NP?
@@ -53,7 +53,7 @@ export default { | |||
'!src/legacy/core_plugins/**/__snapshots__/**/*', | |||
], | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context is to allow nested folders?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well but since we might hit that problem another time I might just leave it, since you anyway already approved it :)
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.
jest config LGTM
💚 Build Succeeded |
💚 Build Succeeded |
💚 Build Succeeded |
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 one last question :)
@@ -17,7 +17,7 @@ | |||
* under the License. | |||
*/ | |||
|
|||
import { parseInterval } from '../utils/parse_interval'; | |||
import { isValidEsInterval } from '../../../core_plugins/data/common'; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
dateHistogramInterval
utility, which can be used to calculate the correct interval key (calendar_interval
orfixed_interval
) for a given interval string (like10s
,1h
, etc.).The return will be an object that can simply spreaded into a
date_histogram
body. So you should replace your previousinterval
key 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 theisValidEsInterval
function 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/common
folder (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