-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
fix(native-filters): avoid double load on select initialization #15012
Conversation
@@ -109,6 +109,7 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) { | |||
} = formData; | |||
const groupby = ensureIsArray<string>(formData.groupby); | |||
const [col] = groupby; | |||
const [initialColtypeMap] = useState(coltypeMap); |
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.
I'm not sure if this proposal will be rellevant, but may be it can make sense instead of split state to different places we can control calls of setDataMask
hook, for example - not call it if doesn't have filled own state or stuff like that, because if we will have some more logic for own state we can get same issue, or may be I wrong
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.
I think we should ultimately make the chart component check if a call to buildQuery
actually returns a changed query. This way we could avoid retriggering queries when ownState
changes but the actual QueryObject
s or QueryContext
doesn't change.
* upstream/master: fix(explore): Datepicker glitch on hover outside the modal (apache#15033) Add ming-height to empty tab (apache#14878) Remove nowrap (apache#14954) display all metric results in editor (apache#15031) feat: Add "is_select_query" method to base engine spec to make it possible to override it (apache#15013) fix(dashboard): custom css should be removed on unmount (apache#15025) feat(filter-box): hide druid options if druid not enabled (apache#14921) fix: adding additional configs and colors for queryHistory (apache#14995) chore: rename 'Source' to 'Database' for consistency (apache#15021) chore(ci): fix ci conflict (apache#15016) fix(native-filters): avoid double load on initialization (apache#15012) feat(native-filters): Support default to first value in select filter (apache#14869) docs: required information for OAuth2 configuration (apache#15010) Update index.mdx (apache#14990)
SUMMARY
Currently select filters make two requests for data upon initialization. This is due to the filter adding column type mappings to
ownState
on initialization. Since these are only needed when "Search all options" is enabled, the initial column type mappings are stored on initialization, and are added toownState
only when needed.BEFORE
Currently the "Continent" filter generates two requests (the last two requests to "data"); the first with
![image](https://user-images.githubusercontent.com/33317356/120992544-61cae300-c78b-11eb-82a4-917ada9cf81b.png)
ownState: {}
and the second withownState: { colTypeMap: region: 1 }
. Note that the request is the same, due toownState
not changing the generated query inbuildQuery
:AFTER
Now loading the Filter Tab only causes one single request on initialization, both when "Search all options" is enabled and disabled (
![image](https://user-images.githubusercontent.com/33317356/120992416-41028d80-c78b-11eb-9b37-e0c2034036ab.png)
ownState
is added todataMask
when the first update happens):BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Updated tests + added new test to ensure that
ownState
is populated correctly whensearchAllOptions
istrue
.ADDITIONAL INFORMATION