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: custom favorite filter for dashboards, charts and saved queries #11083

Merged
merged 13 commits into from
Oct 1, 2020

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Sep 27, 2020

SUMMARY

Add a new custom filter to fetch a user's favorite and not favorite dashboards, slices or saved queries

Rison/JSON arguments:

{
    "filters": [
        {"col": "id", "opr": "dashboard_is_fav", "value": true}
    ]
}
{
    "filters": [
        {"col": "id", "opr": "chart_is_fav", "value": true}
    ]
}
{
    "filters": [
        {"col": "id", "opr": "saved_query_is_fav", "value": true}
    ]
}

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

codecov-commenter commented Sep 27, 2020

Codecov Report

Merging #11083 into master will increase coverage by 4.17%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11083      +/-   ##
==========================================
+ Coverage   61.64%   65.81%   +4.17%     
==========================================
  Files         815      815              
  Lines       38498    38512      +14     
  Branches     3620     3620              
==========================================
+ Hits        23733    25348    +1615     
+ Misses      14579    13054    -1525     
+ Partials      186      110      -76     
Flag Coverage Δ
#cypress 56.39% <ø> (?)
#javascript 62.05% <ø> (ø)
#python 61.36% <85.71%> (-0.05%) ⬇️

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

Impacted Files Coverage Δ
superset/dashboards/filters.py 92.50% <81.81%> (-4.06%) ⬇️
superset/dashboards/api.py 80.86% <100.00%> (ø)
superset/db_engine_specs/mysql.py 79.59% <0.00%> (-12.25%) ⬇️
...et-frontend/src/SqlLab/components/LimitControl.tsx 84.78% <0.00%> (-1.89%) ⬇️
superset/models/core.py 87.56% <0.00%> (-0.83%) ⬇️
superset/views/core.py 73.92% <0.00%> (-0.25%) ⬇️
...ontend/src/components/ListView/TableCollection.tsx 100.00% <0.00%> (ø)
...-frontend/src/datasource/ChangeDatasourceModal.tsx 75.00% <0.00%> (+0.45%) ⬆️
superset-frontend/src/SqlLab/actions/sqlLab.js 60.25% <0.00%> (+0.64%) ⬆️
...erset-frontend/src/SqlLab/components/SqlEditor.jsx 52.12% <0.00%> (+1.21%) ⬆️
... and 168 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 7f1e4e4...59733d3. Read the comment docs.

@dpgaspar dpgaspar changed the title feat: custom favorite filter for dashboards feat: custom favorite filter for dashboards, charts and saved queries Sep 27, 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.

One comment on API consistency, but other than that looks good!

superset/charts/filters.py Show resolved Hide resolved
"""

name = _("Is favorite")
arg_name = ""
Copy link
Member

Choose a reason for hiding this comment

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

We could even leverage this default and leave it blank in the subclasses :) (re: favorited)

Copy link
Member Author

Choose a reason for hiding this comment

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

True, nice catch!

Choose a reason for hiding this comment

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

I would create a BaseOuterJoinFilter with "where" and "on" arguments and then extend it

Copy link
Member Author

Choose a reason for hiding this comment

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

That's interesting can you add more detail or an example?

@willbarrett
Copy link
Member

Added @rusackas as his team will be consuming these API changes as well.

@rusackas
Copy link
Member

And on that note, a ping to @pkdotson

data = json.loads(rv.data.decode("utf-8"))
self.assertEqual(data["count"], len(expected_models))
assert rv.status_code == 200

Choose a reason for hiding this comment

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

why not use self.assert200(rv)?

Copy link
Member Author

@dpgaspar dpgaspar Oct 1, 2020

Choose a reason for hiding this comment

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

Because it's used nowhere on the test codebase, not written in stone but with pytest now, we are slowly refactoring to use assert

data = json.loads(rv.data.decode("utf-8"))
self.assertEqual(data["count"], len(expected_models))
assert rv.status_code == 200
assert len(expected_models) == data["count"]

Choose a reason for hiding this comment

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

why did you change it to basic assert?

Copy link
Member Author

Choose a reason for hiding this comment

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

not written in stone but with pytest now, we are slowly refactoring to use assert

yield dashboards

# rollback changes
for dashboard in dashboards:

Choose a reason for hiding this comment

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

is that rollback will also remove from dashboard_user table and dashboard_slices ?

Copy link
Member Author

@dpgaspar dpgaspar Oct 1, 2020

Choose a reason for hiding this comment

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

Good point. But, yes it cleans up after dashboard_user and no dashboard_slices are added so nothing to do here

)
arguments["filters"][0]["value"] = False
uri = f"api/v1/dashboard/?q={prison.dumps(arguments)}"
rv = self.client.get(uri)

Choose a reason for hiding this comment

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

why not separate to another test case ?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, done that

"""

name = _("Is favorite")
arg_name = ""

Choose a reason for hiding this comment

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

I would create a BaseOuterJoinFilter with "where" and "on" arguments and then extend it

@willbarrett willbarrett merged commit 4c85d33 into apache:master Oct 1, 2020
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
…apache#11083)

* feat: custom favorite filter for dashboards

* lint and sort

* add favored for charts

* fix tests and lint

* more tests and saved query filter

* fix tests

* fix tests

* lint

* lint and fix conflict

* remove unnecessary prop

* separate tests
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label 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/L 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants