Skip to content

Commit

Permalink
[hotfix] caching and list ordering related bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jun 21, 2016
1 parent 7c2d485 commit a9fd227
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ def flat_form_fields(cls):
def reassignments(self):
pass

def get_url(self, **kwargs):
"""Returns the URL for the viz"""
def get_url(self, for_cache_key=False, **kwargs):
"""Returns the URL for the viz
:param for_cache_key: when getting the url as the identifier to hash
for the cache key
:type for_cache_key: boolean
"""
d = self.orig_form_data.copy()
if 'json' in d:
del d['json']
Expand All @@ -124,11 +129,13 @@ def get_url(self, **kwargs):
v = d.get(key)
if not isinstance(v, list):
v = [v]
for item in sorted(v):
for item in v:
od.add(key, item)
href = Href(
'/caravel/explore/{self.datasource.type}/'
'{self.datasource.id}/'.format(**locals()))
if for_cache_key and 'force' in od:
del od['force']
return href(od)

def get_df(self, query_obj=None):
Expand Down Expand Up @@ -316,7 +323,7 @@ def json_endpoint(self):

@property
def cache_key(self):
url = self.get_url(json="true", force="false")
url = self.get_url(for_cache_key=True, json="true", force="false")
return hashlib.md5(url.encode('utf-8')).hexdigest()

@property
Expand Down

0 comments on commit a9fd227

Please sign in to comment.