diff --git a/lib/cartodb/models/mapconfig_overviews_adapter.js b/lib/cartodb/models/mapconfig_overviews_adapter.js index d3fcedc0..f9f580a8 100644 --- a/lib/cartodb/models/mapconfig_overviews_adapter.js +++ b/lib/cartodb/models/mapconfig_overviews_adapter.js @@ -50,12 +50,16 @@ MapConfigOverviewsAdapter.prototype.getLayers = function(username, layers, analy function collectStatsData(err, filters, unfiltered_query) { var next_step = this; if ( filters ) { - self.filterStatsApi.getFilterStats(username, unfiltered_query, filters, function(err, stats) { - if ( !err ) { - query_rewrite_data.filter_stats = stats; + self.filterStatsApi.getFilterStats( + username, + unfiltered_query, filters, + function(err, stats) { + if ( !err ) { + query_rewrite_data.filter_stats = stats; + } + return next_step(err); } - return next_step(err); - }); + ); } else { return next_step(null); } diff --git a/lib/cartodb/utils/overviews_query_rewriter.js b/lib/cartodb/utils/overviews_query_rewriter.js index 4025e3f0..faad459d 100644 --- a/lib/cartodb/utils/overviews_query_rewriter.js +++ b/lib/cartodb/utils/overviews_query_rewriter.js @@ -291,13 +291,12 @@ function overviews_query(query, overviews, zoom_level, zoom_level_expression) { function should_use_overviews(query, data) { data = data || {}; var use_overviews = data.overviews && is_supported_query(query); - if ( use_overviews ) { - if ( data.filters && data.filter_stats ) { - var filtered_rows = data.filter_stats.filtered_rows; - var unfiltered_rows = data.filter_stats.unfiltered_rows; - if ( unfiltered_rows && (filtered_rows || filtered_rows === 0) ) { - use_overviews = filtered_rows >= FILTER_MIN_ROWS || (filtered_rows/unfiltered_rows) > FILTER_MAX_FRACTION; - } + if ( use_overviews && data.filters && data.filter_stats ) { + var filtered_rows = data.filter_stats.filtered_rows; + var unfiltered_rows = data.filter_stats.unfiltered_rows; + if ( unfiltered_rows && (filtered_rows || filtered_rows === 0) ) { + use_overviews = filtered_rows >= FILTER_MIN_ROWS || + (filtered_rows/unfiltered_rows) > FILTER_MAX_FRACTION; } } return use_overviews;