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(dashboard): dashboard/id/datasets endpoint #13523

Merged
merged 8 commits into from Mar 12, 2021

Conversation

suddjian
Copy link
Member

@suddjian suddjian commented Mar 9, 2021

SUMMARY

Adding a new endpoint that gets the dataset metadata for a dashboard.

This is intended to replace the template-loaded bootstrap data on the dashboard page. In keeping with the precedent set by the existing bootstrap data, I have opted to return data in the same shape (a map of datasets) rather than a list, and to copy the bootstrap data's "trimming" behavior where any data unnecessary for rendering the dashboard is stripped out of the result. I don't believe these design decisions make for the ideal endpoint, but they do reduce potential regressions in the Single Page App project.

TEST PLAN

Wrote unit tests, tested manually

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Mar 9, 2021

Codecov Report

Merging #13523 (82527f5) into master (c8759a3) will decrease coverage by 5.96%.
The diff coverage is 50.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13523      +/-   ##
==========================================
- Coverage   77.45%   71.49%   -5.97%     
==========================================
  Files         906      824      -82     
  Lines       45825    41189    -4636     
  Branches     5530     4261    -1269     
==========================================
- Hits        35495    29448    -6047     
- Misses      10202    11741    +1539     
+ Partials      128        0     -128     
Flag Coverage Δ
cypress 57.19% <37.45%> (-0.72%) ⬇️
hive 80.19% <88.23%> (+0.13%) ⬆️
javascript ?
mysql 80.52% <89.30%> (+0.12%) ⬆️
postgres 80.56% <89.30%> (+0.12%) ⬆️
presto 80.23% <88.23%> (+0.13%) ⬆️
python 81.06% <89.30%> (+0.12%) ⬆️
sqlite 80.18% <87.70%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
...end/src/SqlLab/components/TemplateParamsEditor.jsx 23.80% <ø> (ø)
superset-frontend/src/chart/ChartContainer.jsx 100.00% <ø> (ø)
...ontend/src/common/components/InfoTooltip/index.tsx 33.33% <ø> (ø)
superset-frontend/src/common/components/index.tsx 100.00% <ø> (ø)
...-frontend/src/components/AlteredSliceTag/index.jsx 92.00% <ø> (ø)
...rontend/src/components/AsyncEsmComponent/index.tsx 94.11% <ø> (ø)
superset-frontend/src/components/Badge/index.tsx 25.00% <ø> (ø)
...nd/src/components/BootstrapSliderWrapper/index.jsx 0.00% <ø> (ø)
superset-frontend/src/components/Button/index.tsx 100.00% <ø> (ø)
...perset-frontend/src/components/ChartIcon/index.tsx 50.00% <ø> (ø)
... and 601 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8759a3...9e46615. Read the comment docs.

@amitmiran137 amitmiran137 changed the title feat(dashboard) dashboard/id/datasets endpoint feat(dashboard: dashboard/id/datasets endpoint Mar 9, 2021
@suddjian suddjian changed the title feat(dashboard: dashboard/id/datasets endpoint feat(dashboard): dashboard/id/datasets endpoint Mar 10, 2021
@junlincc junlincc added the SPA label Mar 10, 2021
Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

Looks good left a couple of comments

)
dashboard = query.one_or_none()
if not dashboard:
raise DashboardNotFoundError()
Copy link
Member

Choose a reason for hiding this comment

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

Feels kind of strange that a DAO raises a Command Exception

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I never noticed that. It also feels kind of strange to create multiple different exception classes with the exact same meaning. I think it's reasonable to share them.

type: object
properties:
result:
type: object
Copy link
Member

Choose a reason for hiding this comment

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

Better to declare a marshmallow schema and reference it here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, but please check over my schema for any issues because it's a big one

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM - just one minor improvement proposal for tests.

Comment on lines 181 to 182
dataset_ids = set([s.datasource_id for s in dashboard.slices])
self.assertEqual(len(data["result"]), len(dataset_ids))
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could probably compare a set of ids from data["result"] with dataset_ids here to make sure the ids are identical.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 11, 2021
@suddjian suddjian merged commit 1b95ed7 into apache:master Mar 12, 2021
@suddjian suddjian deleted the dashboard-dataset-endpoint branch March 12, 2021 01:43
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
* feat(dashboard) dashboard/id/datasets endpoint

* schema for dashboard datasets

* list instead of map

* finish dashboard dataset schema

* description

* better test

* add the dataset schema to the schema list

* lint
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.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 preset-io size/L SPA 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants