diff --git a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js index a99eeaef..3897121a 100644 --- a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js @@ -101,10 +101,8 @@ module.exports = class AggregationMapConfigAdapter { } _shouldAdaptLayer (connection, mapConfig, layer, index, callback) { - let shouldAdapt = false; - if (!mapConfig.isAggregationLayer(index)) { - return callback(null, shouldAdapt); + return callback(null, false); } const aggregationMetadata = queryUtils.getAggregationMetadata({ @@ -113,22 +111,22 @@ module.exports = class AggregationMapConfigAdapter { connection.query(aggregationMetadata, (err, res) => { if (err) { - return callback(null, shouldAdapt); + return callback(null, false); } const result = res.rows[0] || {}; if (!mapConfig.doesLayerReachThreshold(index, result.count)) { - return callback(null, shouldAdapt); + return callback(null, false); } if (!AggregationMapConfig.supportsGeometryType(result.type)) { - return callback(new Error(unsupportedGeometryTypeErrorMessage({ geometryType: result.type }))); + return callback(new Error(unsupportedGeometryTypeErrorMessage({ + geometryType: result.type + }))); } - shouldAdapt = true; - - callback(null, shouldAdapt); + callback(null, true); }); }