-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Lens as code] Fix temporal scale on x axis and histogram brush #264134
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c5ad77d
Extract getESQLTimeFieldFromQuery
markov00 42f3662
pass just the timefield + clear the dataview cache
markov00 9f173d7
fix time scale + histogram brush
markov00 0c6e291
fix test and update extended data layer logic
markov00 c32e5f0
Merge branch 'main' into 2026_04_17_fix_timefield_n3
markov00 9ff531f
Merge remote-tracking branch 'upstream/main' into 2026_04_17_fix_time…
markov00 f990714
add functional test
markov00 ebb3ae8
move tests to parallel tests
markov00 68b9222
update scout test with proposed guidelines
markov00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/platform/packages/shared/kbn-esql-utils/src/utils/get_esql_time_field_from_query.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
| import type { HttpStart } from '@kbn/core/public'; | ||
| import { TIMEFIELD_ROUTE } from '@kbn/esql-types'; | ||
| import { LRUCache } from 'lru-cache'; | ||
|
|
||
| // Caches the in-flight or resolved TIMEFIELD_ROUTE promise by query. | ||
| // Storing the Promise (not the resolved value) deduplicates concurrent calls: | ||
| // if multiple callers request the same query before the first resolves, | ||
| // they all await the same promise instead of each firing a separate HTTP request. | ||
| const timeFieldCache = new LRUCache<string, Promise<string | undefined>>({ max: 100 }); | ||
|
|
||
| /** | ||
| * Resolves the default time field for an ES|QL query by calling the timefield API. | ||
| * | ||
| * When `http` is omitted, returns `undefined` (unless a prior successful request | ||
| * for the same query left a value in the in-memory cache). | ||
| * | ||
| * Concurrent requests for the same query share one HTTP request via an LRU-backed promise cache. | ||
| */ | ||
| export async function getESQLTimeFieldFromQuery({ | ||
| query, | ||
| http, | ||
| }: { | ||
| query: string; | ||
| http?: HttpStart; | ||
| }): Promise<string | undefined> { | ||
| const cached = timeFieldCache.get(query); | ||
| if (cached !== undefined) { | ||
| return cached; | ||
| } | ||
| if (!http) { | ||
| return undefined; | ||
| } | ||
| const pendingRequest = http | ||
| .post(TIMEFIELD_ROUTE, { body: JSON.stringify({ query }) }) | ||
| .then((response) => (response as { timeField?: string } | undefined)?.timeField) | ||
| .catch((error) => { | ||
| // eslint-disable-next-line no-console | ||
| console.error('Failed to fetch the timefield', error); | ||
| timeFieldCache.delete(query); | ||
| return undefined; | ||
| }); | ||
| timeFieldCache.set(query, pendingRequest); | ||
| return pendingRequest; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.