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

[Adhoc Filters] integrating dashboard filters with adhoc filters #5056

Merged
merged 1 commit into from
May 23, 2018

Conversation

gabe-lyons
Copy link
Contributor

@gabe-lyons gabe-lyons commented May 22, 2018

Thanks to @michellethomas for reporting. Filters on dashboards were not compatible with adhoc filters. This PR essentially factors out adhoc_filter => legacy filter conversion into a util function and then calls it both places merge_extra_filters is called.

relevant issue: #5049

image

test plan:

  • created a dashboard locally with a filter
  • added slices with no filters, with adhoc_filters and with legacy filters
  • applied the filter to dashboard
  • verified all the slices incorporated the filter when rendering
  • clicked on various slices
  • verified they all had the dashboard's filter applied in the explore view

reviewers:
@michellethomas @john-bodley @graceguo-supercat @williaster @mistercrunch

@gabe-lyons gabe-lyons force-pushed the gabe_fixing_dashboard_filters branch 2 times, most recently from f5ed925 to b3c92ff Compare May 22, 2018 21:38
@gabe-lyons gabe-lyons changed the title [WIP] integrating dashboard filters with adhoc filters [Adhoc Filters] integrating dashboard filters with adhoc filters May 22, 2018
@codecov-io
Copy link

codecov-io commented May 22, 2018

Codecov Report

Merging #5056 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5056      +/-   ##
==========================================
+ Coverage   77.52%   77.53%   +<.01%     
==========================================
  Files          44       44              
  Lines        8707     8710       +3     
==========================================
+ Hits         6750     6753       +3     
  Misses       1957     1957
Impacted Files Coverage Δ
superset/viz.py 81.42% <100%> (-0.29%) ⬇️
superset/utils.py 88.52% <100%> (+0.61%) ⬆️
superset/views/core.py 74.66% <100%> (+0.01%) ⬆️

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 4c44223...eadb9c5. Read the comment docs.

@@ -841,3 +841,39 @@ def ensure_path_exists(path):
except OSError as exc:
if not (os.path.isdir(path) and exc.errno == errno.EEXIST):
raise


def split_adhoc_filters_into_legacy_filters(fd):
Copy link
Contributor

@michellethomas michellethomas May 22, 2018

Choose a reason for hiding this comment

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

Can you add a docstring here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Calling it "legacy" filters sounds a little to me like this is legacy code that will be cleaned up eventually, but this translation will be sticking around correct? I wonder if there's a word other than "legacy" that would describe this. I'm fine if not though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gabe-lyons gabe-lyons force-pushed the gabe_fixing_dashboard_filters branch from b3c92ff to 999f7a4 Compare May 22, 2018 22:38
@@ -841,3 +841,45 @@ def ensure_path_exists(path):
except OSError as exc:
if not (os.path.isdir(path) and exc.errno == errno.EEXIST):
raise


def split_adhoc_filters_into_base_filters(fd):
Copy link
Member

Choose a reason for hiding this comment

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

Typically we use the form_data variable to represent form data. It's probably best to rename fd to form_data for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@john-bodley fd is used throughout the codebase already

@@ -1279,6 +1279,7 @@ def explore(self, datasource_type=None, datasource_id=None):
form_data['datasource'] = str(datasource_id) + '__' + datasource_type

# On explore, merge extra filters into the form data
form_data = utils.split_adhoc_filters_into_base_filters(form_data)
Copy link
Member

Choose a reason for hiding this comment

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

Your function mutates the form data so there's no need to re-assign. You can either make split_adhoc_filters_into_base_filters create a copy and return the mutated copy or simply mutate the input which seems to be the pattern as per line #243.

superset/viz.py Outdated
# extras are used to query elements specific to a datasource type
# for instance the extra where clause that applies only to Tables

form_data = utils.split_adhoc_filters_into_base_filters(form_data)
Copy link
Member

Choose a reason for hiding this comment

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

See ^^.

@gabe-lyons gabe-lyons force-pushed the gabe_fixing_dashboard_filters branch from 999f7a4 to eadb9c5 Compare May 22, 2018 22:56
Copy link
Member

@john-bodley john-bodley left a comment

Choose a reason for hiding this comment

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

@GabeLoins a couple of small nits, but otherwise LGTM.

# Add extra filters into the query form data
# extras are used to query elements specific to a datasource type
# for instance the extra where clause that applies only to Tables

Copy link
Member

Choose a reason for hiding this comment

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

Nit. Remove blank line.

# for instance the extra where clause that applies only to Tables

utils.split_adhoc_filters_into_base_filters(form_data)

Copy link
Member

Choose a reason for hiding this comment

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

Nit. Remove blank line.

@john-bodley john-bodley merged commit fa3e4e2 into apache:master May 23, 2018
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
john-bodley added a commit that referenced this pull request May 24, 2018
timifasubaa pushed a commit to timifasubaa/incubator-superset that referenced this pull request May 31, 2018
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.26.0 labels Feb 27, 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 🚢 0.26.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants