You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2017/11/15 05:12:28 UTC
[incubator-superset] branch master updated: [cache] Fixing cache
key w/ merged extra filters (#3809)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new ba89b2d [cache] Fixing cache key w/ merged extra filters (#3809)
ba89b2d is described below
commit ba89b2d0913b769c4b01b976ccd65031e2f98dbc
Author: John Bodley <45...@users.noreply.github.com>
AuthorDate: Tue Nov 14 21:12:26 2017 -0800
[cache] Fixing cache key w/ merged extra filters (#3809)
---
superset/utils.py | 4 ++--
superset/viz.py | 4 +++-
tests/utils_tests.py | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/superset/utils.py b/superset/utils.py
index 42f2da3..469bbc2 100644
--- a/superset/utils.py
+++ b/superset/utils.py
@@ -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
diff --git a/superset/viz.py b/superset/viz.py
index e1ebe74..8a90c81 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -220,7 +220,9 @@ class BaseViz(object):
@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):
diff --git a/tests/utils_tests.py b/tests/utils_tests.py
index 1d5cc65..f6d1901 100644
--- a/tests/utils_tests.py
+++ b/tests/utils_tests.py
@@ -61,9 +61,9 @@ class UtilsTestCase(unittest.TestCase):
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
--
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <co...@superset.apache.org>'].