Skip to content

Commit

Permalink
[hotfix] periodic refresh dashboard feature had broken caching
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 25, 2016
1 parent 37be01b commit 7b10759
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions caravel/assets/javascripts/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var Dashboard = function (dashboardData) {
filters: {},
init: function () {
this.initDashboardView();
this.firstLoad = true;
px.initFavStars();
var sliceObjects = [],
dash = this;
Expand Down Expand Up @@ -67,15 +68,17 @@ var Dashboard = function (dashboardData) {
startPeriodicRender: function (interval) {
this.stopPeriodicRender();
var dash = this;
var maxRandomDelay = Math.min(interval * 0.1, 5000);
var maxRandomDelay = Math.min(interval * 0.2, 5000);
var refreshAll = function () {
dash.slices.forEach(function (slice) {
var force = !dash.firstLoad;
setTimeout(function () {
slice.render(true);
},
//Randomize to prevent all widgets refreshing at the same time
maxRandomDelay * Math.random());
slice.render(force);
},
//Randomize to prevent all widgets refreshing at the same time
maxRandomDelay * Math.random());
});
dash.firstLoad = false;
};

var fetchAndRender = function () {
Expand Down
7 changes: 5 additions & 2 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ def get_url(self, **kwargs):
del d['action']
d.update(kwargs)
# Remove unchecked checkboxes because HTML is weird like that
for key in d.keys():
od = OrderedDict()
for key in sorted(d.keys()):
if d[key] is False:
del d[key]
else:
od[key] = d[key]
href = Href(
'/caravel/explore/{self.datasource.type}/'
'{self.datasource.id}/'.format(**locals()))
return href(d)
return href(od)

def get_df(self, query_obj=None):
"""Returns a pandas dataframe based on the query object"""
Expand Down

0 comments on commit 7b10759

Please sign in to comment.