From e26cfb2efb96f3fd912277150b5e89e51dbfabbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 12 Dec 2017 13:32:01 +0100 Subject: [PATCH] Remove magic number --- lib/cartodb/models/aggregation/aggregation-proxy.js | 6 +++++- .../mapconfig/adapter/aggregation-mapconfig-adapter.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/models/aggregation/aggregation-proxy.js b/lib/cartodb/models/aggregation/aggregation-proxy.js index aa52e05f..58da647c 100644 --- a/lib/cartodb/models/aggregation/aggregation-proxy.js +++ b/lib/cartodb/models/aggregation/aggregation-proxy.js @@ -4,7 +4,11 @@ const RASTER_AGGREGATION = 'RasterAggregation'; const VECTOR_AGGREGATION = 'VectorAggregation'; module.exports = class AggregationProxy { - constructor (mapconfig, query, { resolution = 256, threshold = 1e5, placement = 'centroid', columns = {}} = {}) { + static get THRESHOLD() { + return 1e5; // 100K + } + + constructor (mapconfig, query, { resolution = 256, threshold = AggregationProxy.THRESHOLD, placement = 'centroid', columns = {}} = {}) { this.mapconfig = mapconfig; this.query = query; this.resolution = resolution; diff --git a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js index c067d17f..7c315f86 100644 --- a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js @@ -177,7 +177,7 @@ module.exports = class AggregationMapConfigAdapter { const threshold = layer.options.aggregation && layer.options.aggregation.threshold ? layer.options.aggregation.threshold : - 1e5; + AggregationProxy.THRESHOLD; if (estimatedFeatureCount < threshold) { return callback(null, shouldAdapt);