From ee63b247cd2875298aa5c6fa6e1f10beb849f341 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Mon, 8 Oct 2018 19:25:04 +0200 Subject: [PATCH] Slight refactor --- lib/cartodb/backends/layer-stats/mapnik-layer-stats.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js b/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js index e54598bb..45bcc58a 100644 --- a/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js +++ b/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js @@ -142,11 +142,18 @@ function _sample(ctx, numRows) { return Promise.resolve(); } +function _columnsMetadataRequired(options) { + // We need determine the columns of a query + // if either column stats or dimension stats are required, + // since we'll ultimately use the same query to fetch both + return options.columnStats || options.dimensions; +} + function _columnStats(ctx, columns, dimensions) { if (!columns) { return Promise.resolve(); } - if (ctx.metaOptions.columnStats || ctx.metaOptions.dimensions) { + if (_columnsMetadataRequired(ctx.metaOptions)) { let queries = []; let aggr = []; if (ctx.metaOptions.columnStats) {