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: new reports models api #11606

Merged
merged 26 commits into from
Nov 12, 2020
Merged

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Nov 6, 2020

SUMMARY

Implements a REST API for alerts and reports.

Note: This feature is behind a new feature flag ALERT_REPORTS

PR 2 reference for the first PR (#11550).

Screenshot 2020-11-09 at 15 15 47

POST payload OpenAPI spec:
Screenshot 2020-11-09 at 16 46 56

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

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-io
Copy link

codecov-io commented Nov 6, 2020

Codecov Report

Merging #11606 (dc3f6aa) into master (bd79bd2) will increase coverage by 0.65%.
The diff coverage is 81.40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11606      +/-   ##
==========================================
+ Coverage   66.41%   67.06%   +0.65%     
==========================================
  Files         878      885       +7     
  Lines       42272    42860     +588     
  Branches     3949     3971      +22     
==========================================
+ Hits        28074    28744     +670     
+ Misses      14095    14018      -77     
+ Partials      103       98       -5     
Flag Coverage Δ
cypress 55.43% <30.68%> (+0.50%) ⬆️
javascript 62.84% <57.00%> (+0.39%) ⬆️
python 62.76% <90.22%> (+0.84%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/chart/Chart.jsx 58.18% <ø> (ø)
...-frontend/src/common/components/common.stories.tsx 0.00% <0.00%> (ø)
...ontend/src/components/ListViewCard/ImageLoader.tsx 86.36% <ø> (ø)
superset-frontend/src/components/Menu/Menu.tsx 94.28% <ø> (ø)
superset-frontend/src/components/Menu/SubMenu.tsx 100.00% <ø> (ø)
.../src/components/dataViewCommon/TableCollection.tsx 100.00% <ø> (ø)
...et-frontend/src/dashboard/actions/sliceEntities.js 75.75% <ø> (ø)
...tend/src/dashboard/components/DashboardBuilder.jsx 85.50% <ø> (-0.41%) ⬇️
.../src/dashboard/components/gridComponents/Chart.jsx 86.02% <ø> (+3.36%) ⬆️
...tend/src/dashboard/containers/DashboardBuilder.jsx 100.00% <ø> (ø)
... and 92 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 bd79bd2...d07e27f. Read the comment docs.

@dpgaspar dpgaspar marked this pull request as ready for review November 9, 2020 16:33
@dpgaspar dpgaspar changed the title feat: new reports models api [WiP] feat: new reports models api Nov 9, 2020
@dpgaspar dpgaspar changed the title [WiP] feat: new reports models api feat: new reports models api Nov 10, 2020
Copy link
Member

@willbarrett willbarrett left a comment

Choose a reason for hiding this comment

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

This is looking really good! A few small things to take care of, but nothing major. Thanks for all this work @dpgaspar !

superset/reports/schemas.py Outdated Show resolved Hide resolved
superset/reports/commands/create.py Outdated Show resolved Hide resolved
self._model = ReportScheduleDAO.find_by_id(self._model_id)
if not self._model:
raise ReportScheduleNotFoundError()
# TODO check integrity
Copy link
Member

Choose a reason for hiding this comment

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

Let's not leave TODOs lying around. Can we address in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's already addressed, this is a left over, like a note to self. (deleted)



class ReportScheduleDeleteIntegrityError(CommandException):
message = _("Report Schedule has associated logs or recipients.")
Copy link
Member

Choose a reason for hiding this comment

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

It should be possible to delete a ReportSchedule with associated logs and recipients. Neither of those related objects have meaningful stand-alone delete operations and they make no sense without the related ReportSchedule record. Let's use a cascading delete and remove this error.

Copy link
Member Author

@dpgaspar dpgaspar Nov 11, 2020

Choose a reason for hiding this comment

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

Totally agree, it's exactly how I done it. Deleted

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.

Wow, super solid work here! 👍 🥇 💯

if report_type == ReportScheduleType.ALERT:
database_id = self._properties.get("database")
if not database_id:
exceptions.append(ReportScheduleAlertRequiredDatabaseValidationError())
Copy link
Member

Choose a reason for hiding this comment

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

While there is objectively nothing wrong with this class name, these are really getting out of hand 🤣

$ echo ReportScheduleAlertRequiredDatabaseValidationError|tr -d '\n' | wc -c
      50

@willbarrett willbarrett merged commit 12cb27f into apache:master Nov 12, 2020
@dpgaspar dpgaspar mentioned this pull request Nov 19, 2020
6 tasks
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* feat: new report schedule models

* lint and unique constraint

* support sqlite

* fix sqlite

* add audit mixin and minor fixes

* feat(api): alerts and reports REST API

* feat: new report schedule models

* lint and unique constraint

* support sqlite

* fix sqlite

* add audit mixin and minor fixes

* feat(api): alerts and reports REST API

* draft working version

* add tests

* test

* black

* remove copy pasta

* solve dashboard object representation being used on cache

* tests and custom filter

* fix PUT has PATCH on active field

* create feature flag

* fix lint

* address comments
@dpgaspar dpgaspar deleted the feat/reports-models-api branch November 24, 2020 18:00
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.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 size/XXL 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants