From 52630b80847007ee26eec385084aa6649172881b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 1 Dec 2017 17:06:42 +0100 Subject: [PATCH] Minor improvementes --- .../adapter/aggregation-mapconfig-adapter.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js index 07089f41..4e7d229a 100644 --- a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js @@ -1,4 +1,5 @@ const AggregationProxy = require('../../aggregation/aggregation-proxy'); +const { MapConfig } = require('windshaft').model; module.exports = class AggregationMapConfigAdapter { getMapConfig (user, requestMapConfig, params, context, callback) { @@ -6,31 +7,33 @@ module.exports = class AggregationMapConfigAdapter { return callback(null, requestMapConfig); } - requestMapConfig = this._adaptLayers(requestMapConfig); + requestMapConfig.layers = this._adaptLayers(requestMapConfig); callback(null, requestMapConfig); } _shouldAdaptLayers (requestMapConfig, params) { + let shouldAdapt = false; + if (typeof params.aggregation === 'boolean') { - return params.aggregation; + shouldAdapt = params.aggregation; } + const mapConfig = new MapConfig(requestMapConfig); + if (params.aggregation === undefined) { - if (requestMapConfig.isVectorLayergroup()) { - return true; + if (mapConfig.isVectorOnlyMapConfig()) { + shouldAdapt = true; } else if (this._hasAggregation(requestMapConfig)){ - return true; + shouldAdapt = true; } } - return false; + return shouldAdapt; } _hasAggregation (requestMapConfig) { for (const layer of requestMapConfig.layers) { - - if (this._hasLayerAggregation(layer)) { return true; }