Skip to content

Commit

Permalink
[Lens][ES|QL] Do not refetch the attributes if the query hasn't chang…
Browse files Browse the repository at this point in the history
…ed (#195196)

## Summary

When a user is creating a Lens ES|QL chart we run the suggestions api
even if the query hasn't changed. This PR adds a guard to avoid
refetching the attributes when the query hasn't changed at all.
  • Loading branch information
stratoula authored Oct 9, 2024
1 parent 61251bf commit a209fe8
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export function LensEditConfigurationFlyout({
setErrors([]);
updateSuggestion?.(attrs);
}
prevQuery.current = q;
setIsVisualizationLoading(false);
},
[
Expand Down Expand Up @@ -481,7 +482,6 @@ export function LensEditConfigurationFlyout({
query={query}
onTextLangQueryChange={(q) => {
setQuery(q);
prevQuery.current = q;
}}
detectedTimestamp={adHocDataViews?.[0]?.timeFieldName}
hideTimeFilterInfo={hideTimeFilterInfo}
Expand All @@ -497,7 +497,8 @@ export function LensEditConfigurationFlyout({
editorIsInline
hideRunQueryText
onTextLangQuerySubmit={async (q, a) => {
if (q) {
// do not run the suggestions if the query is the same as the previous one
if (q && !isEqual(q, prevQuery.current)) {
setIsVisualizationLoading(true);
await runQuery(q, a);
}
Expand Down

0 comments on commit a209fe8

Please sign in to comment.