diff --git a/lib/cartodb/backends/cluster.js b/lib/cartodb/backends/cluster.js index 31a2c7e9..8ad2343c 100644 --- a/lib/cartodb/backends/cluster.js +++ b/lib/cartodb/backends/cluster.js @@ -7,7 +7,7 @@ const AggregationMapConfig = require('../models/aggregation/aggregation-mapconfi module.exports = class ClusterBackend { // TODO: reduce complexity - // jshint maxcomplexity: 16 + // jshint maxcomplexity: 15 getClusterFeatures (mapConfigProvider, params, callback) { mapConfigProvider.getMapConfig((err, _mapConfig) => { if (err) { @@ -61,7 +61,7 @@ module.exports = class ClusterBackend { const { columns, expressions } = aggregation; - if (!Array.isArray(columns) || !columns.length) { + if (!hasColumns(columns)) { const error = new Error( `Invalid aggregation input, columns should be and array of column names` ); @@ -261,3 +261,7 @@ function hasAggregationLayer (mapConfig, layerIndex) { return mapConfig.isAggregationLayer(layerIndex); } + +function hasColumns (columns) { + return Array.isArray(columns) && columns.length; +}