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

fix(native-filters): avoid double load on select initialization #15012

Merged
merged 1 commit into from
Jun 7, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Jun 7, 2021

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 to ownState only when needed.

BEFORE

Currently the "Continent" filter generates two requests (the last two requests to "data"); the first with ownState: {} and the second with ownState: { colTypeMap: region: 1 }. Note that the request is the same, due to ownState not changing the generated query in buildQuery:
image

AFTER

Now loading the Filter Tab only causes one single request on initialization, both when "Search all options" is enabled and disabled (ownState is added to dataMask when the first update happens):
image

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Updated tests + added new test to ensure that ownState is populated correctly when searchAllOptions is true.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@villebro villebro changed the title fix(native-filters): avoid double load on initialization fix(native-filters): avoid double load on select initialization Jun 7, 2021
@@ -109,6 +109,7 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
} = formData;
const groupby = ensureIsArray<string>(formData.groupby);
const [col] = groupby;
const [initialColtypeMap] = useState(coltypeMap);
Copy link
Contributor

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

Copy link
Member Author

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 QueryObjects or QueryContext doesn't change.

@villebro villebro merged commit d2a6e8c into apache:master Jun 7, 2021
@villebro villebro deleted the villebro/select-ownstate branch June 7, 2021 10:47
@villebro villebro mentioned this pull request Jun 7, 2021
8 tasks
@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Jun 7, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Jun 8, 2021
* 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)
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels dashboard:native-filters Related to the native filters of the Dashboard preset-io size/M 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants