Skip to content
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

[Lens][ES|QL] Do not refetch the attributes if the query hasn't changed #195196

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,24 +322,29 @@ export function LensEditConfigurationFlyout({

const runQuery = useCallback(
async (q: AggregateQuery, abortController?: AbortController) => {
const attrs = await getSuggestions(
q,
startDependencies,
datasourceMap,
visualizationMap,
adHocDataViews,
setErrors,
abortController,
setDataGridAttrs
);
// do not run the suggestions if the query is the same as the previous one
const attrs = isEqual(q, prevQuery.current)
? attributes
: await getSuggestions(
markov00 marked this conversation as resolved.
Show resolved Hide resolved
q,
startDependencies,
datasourceMap,
visualizationMap,
adHocDataViews,
setErrors,
abortController,
setDataGridAttrs
);
if (attrs) {
setCurrentAttributes?.(attrs);
setErrors([]);
updateSuggestion?.(attrs);
}
prevQuery.current = q;
setIsVisualizationLoading(false);
},
[
attributes,
startDependencies,
datasourceMap,
visualizationMap,
Expand Down Expand Up @@ -481,7 +486,6 @@ export function LensEditConfigurationFlyout({
query={query}
onTextLangQueryChange={(q) => {
setQuery(q);
prevQuery.current = q;
}}
detectedTimestamp={adHocDataViews?.[0]?.timeFieldName}
hideTimeFilterInfo={hideTimeFilterInfo}
Expand Down