From 63e4bcebefdd77f6be347472268f05bb9b11b02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 2 Aug 2018 13:13:48 +0200 Subject: [PATCH] Move function to class as private method --- .../adapter/mapconfig-overviews-adapter.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js b/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js index a50bfae0..e67a2513 100644 --- a/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js @@ -18,16 +18,7 @@ MapConfigOverviewsAdapter.prototype.getMapConfig = function (user, requestMapCon var augmentLayersQueue = queue(layers.length); - layers.forEach(function (layer) { - augmentLayersQueue.defer( - augmentLayer, - this.overviewsMetadataBackend, - this.filterStatsBackend, - user, - layer, - analysesResults - ); - }); + layers.forEach(layer => augmentLayersQueue.defer(this._augmentLayer.bind(this), user, layer, analysesResults)); augmentLayersQueue.awaitAll(function layersAugmentQueueFinish (err, layers) { if (err) { @@ -44,12 +35,12 @@ MapConfigOverviewsAdapter.prototype.getMapConfig = function (user, requestMapCon }); }; -function augmentLayer(overviewsMetadataBackend, filterStatsBackend, user, layer, analysesResults, callback) { +MapConfigOverviewsAdapter.prototype._augmentLayer = function (user, layer, analysesResults, callback) { if (layer.type !== 'mapnik' && layer.type !== 'cartodb') { return callback(null, layer); } - overviewsMetadataBackend.getOverviewsMetadata(user, layer.options.sql, function (err, metadata) { + this.overviewsMetadataBackend.getOverviewsMetadata(user, layer.options.sql, (err, metadata) => { if (err) { return callback(err, layer); } @@ -70,7 +61,7 @@ function augmentLayer(overviewsMetadataBackend, filterStatsBackend, user, layer, var unfilteredQuery = getUnfilteredQuery(analysesResults, layer); - filterStatsBackend.getFilterStats(user, unfilteredQuery, filters, function (err, stats) { + this.filterStatsBackend.getFilterStats(user, unfilteredQuery, filters, function (err, stats) { if (err) { return callback(null, layer); } @@ -83,7 +74,7 @@ function augmentLayer(overviewsMetadataBackend, filterStatsBackend, user, layer, return callback(null, layer); }); }); -} +}; function getRootNode (analysesResults, sourceId) { var node = _.find(analysesResults, function (a) {