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

[cache] Fixing cache key w/ merged extra filters #3809

Merged
merged 1 commit into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions superset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ def get_celery_app(config):
def merge_extra_filters(form_data):
# extra_filters are temporary/contextual filters that are external
# to the slice definition. We use those for dynamic interactive
# filters like the ones emitted by the 'Filter Box' visualization
if form_data.get('extra_filters'):
# filters like the ones emitted by the "Filter Box" visualization
if 'extra_filters' in form_data:
# __form and __to are special extra_filters that target time
# boundaries. The rest of extra_filters are simple
# [column_name in list_of_values]. `__` prefix is there to avoid
Expand Down
4 changes: 3 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ def get_json(self, force=False):

@property
def cache_key(self):
s = str([(k, self.form_data[k]) for k in sorted(self.form_data.keys())])
form_data = self.form_data.copy()
merge_extra_filters(form_data)
s = str([(k, form_data[k]) for k in sorted(form_data.keys())])
return hashlib.md5(s.encode('utf-8')).hexdigest()

def get_annotations(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def test_merge_extra_filters(self):
expected = {'A': 1, 'B': 2, 'c': 'test'}
merge_extra_filters(form_data)
self.assertEquals(form_data, expected)
# does nothing if empty extra_filters
# empty extra_filters
form_data = {'A': 1, 'B': 2, 'c': 'test', 'extra_filters': []}
expected = {'A': 1, 'B': 2, 'c': 'test', 'extra_filters': []}
expected = {'A': 1, 'B': 2, 'c': 'test', 'filters': []}
merge_extra_filters(form_data)
self.assertEquals(form_data, expected)
# copy over extra filters into empty filters
Expand Down