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

feat: Reuse Dashboard redux data in Explore #20850

Closed
wants to merge 1 commit into from

Conversation

kgabryje
Copy link
Member

SUMMARY

Reopen #20668

Currently when user open Explore, we always send a request to /v1/explore endpoint, which assembles Explore initial data - slice, form_data and datasource.
When user goes to Explore from Dashboard (by clicking "Edit chart" or chart title), most of the data needed to assemble Explore should already be available in Redux store.
This PR implements using data from Dashboard Redux store to initialize Explore without calling /v1/explore endpoint.

If user opens Explore from Dashboard, check if slice, formData, datasourceId and datasourceType are available. If they are, fetch datasource metadata and hydrate Explore using slice, formData and datasource.
If they are not available, call /v1/explore and hydrate Explore.

We can't reuse datasource from Dashboard. Datasources metadata on Dashboard is trimmed so that datasource contains only columns and metrics used by charts on that dashboard. In Explore we need to be able to access all columns and metrics, which means we must fetch those from API.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

  1. Go to dashboard
  2. Click "Edit chart"
  3. Verify that Explore has opened correctly and that we did not call /v1/explore/ endpoint
  4. Enter Explore from any other entry point (for example Charts list or Welcome page)
  5. Verify that we do call /v1/explore

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • 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

@kgabryje
Copy link
Member Author

@jinghua-qa Could you please help with testing? This PR was previously reverted due to a bug that went unnoticed, I'm hoping to avoid repeating this mistake.

is_managed_externally = fields.Boolean(
description=is_managed_externally_description
)
owners = fields.List(fields.Nested(UserSchema))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a minor suggestion from recent fixing. the owners fields suggest that align with Dashboard field to owners = fields.List(fields.Dict()).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm getting a 500 from the dashboard endpoint with that change
image

@codecov
Copy link

codecov bot commented Jul 25, 2022

Codecov Report

Merging #20850 (0ee7bb2) into master (0945d4a) will decrease coverage by 0.02%.
The diff coverage is 29.62%.

❗ Current head 0ee7bb2 differs from pull request most recent head 5c542ba. Consider uploading reports for the commit 5c542ba to get more accurate results

@@            Coverage Diff             @@
##           master   #20850      +/-   ##
==========================================
- Coverage   66.17%   66.14%   -0.03%     
==========================================
  Files        1757     1757              
  Lines       66867    66866       -1     
  Branches     7077     7077              
==========================================
- Hits        44246    44226      -20     
- Misses      20812    20831      +19     
  Partials     1809     1809              
Flag Coverage Δ
mysql 81.08% <46.15%> (?)
postgres 81.15% <46.15%> (+0.03%) ⬆️
presto ?
python 81.25% <46.15%> (-0.06%) ⬇️
sqlite 79.77% <46.15%> (+0.02%) ⬆️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...d/packages/superset-ui-core/src/utils/isDefined.ts 100.00% <ø> (ø)
...et-frontend/src/components/EditableTitle/index.tsx 64.78% <ø> (ø)
superset-frontend/src/dashboard/actions/hydrate.js 1.96% <0.00%> (ø)
...end/src/dashboard/components/SliceHeader/index.tsx 88.67% <ø> (ø)
...dashboard/components/SliceHeaderControls/index.tsx 65.88% <ø> (ø)
.../src/dashboard/components/gridComponents/Chart.jsx 55.04% <ø> (ø)
superset-frontend/src/explore/ExplorePage.tsx 0.00% <0.00%> (ø)
...set-frontend/src/explore/actions/hydrateExplore.ts 60.00% <ø> (ø)
...ponents/controls/VizTypeControl/VizTypeGallery.tsx 88.17% <ø> (ø)
superset/annotation_layers/annotations/dao.py 88.46% <0.00%> (+3.27%) ⬆️
... and 24 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@kgabryje
Copy link
Member Author

I decided to close this PR - the performance gain from reusing the dashboard redux data was negligible at the cost of increased code complexity, which introduces a greater risk of bugs and regressions.

@kgabryje kgabryje closed this Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants