Move function to class as private method

This commit is contained in:
Daniel García Aubert 2018-08-02 13:13:48 +02:00
parent 593a72a967
commit 63e4bcebef

View File

@ -18,16 +18,7 @@ MapConfigOverviewsAdapter.prototype.getMapConfig = function (user, requestMapCon
var augmentLayersQueue = queue(layers.length); var augmentLayersQueue = queue(layers.length);
layers.forEach(function (layer) { layers.forEach(layer => augmentLayersQueue.defer(this._augmentLayer.bind(this), user, layer, analysesResults));
augmentLayersQueue.defer(
augmentLayer,
this.overviewsMetadataBackend,
this.filterStatsBackend,
user,
layer,
analysesResults
);
});
augmentLayersQueue.awaitAll(function layersAugmentQueueFinish (err, layers) { augmentLayersQueue.awaitAll(function layersAugmentQueueFinish (err, layers) {
if (err) { 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') { if (layer.type !== 'mapnik' && layer.type !== 'cartodb') {
return callback(null, layer); return callback(null, layer);
} }
overviewsMetadataBackend.getOverviewsMetadata(user, layer.options.sql, function (err, metadata) { this.overviewsMetadataBackend.getOverviewsMetadata(user, layer.options.sql, (err, metadata) => {
if (err) { if (err) {
return callback(err, layer); return callback(err, layer);
} }
@ -70,7 +61,7 @@ function augmentLayer(overviewsMetadataBackend, filterStatsBackend, user, layer,
var unfilteredQuery = getUnfilteredQuery(analysesResults, 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) { if (err) {
return callback(null, layer); return callback(null, layer);
} }
@ -83,7 +74,7 @@ function augmentLayer(overviewsMetadataBackend, filterStatsBackend, user, layer,
return callback(null, layer); return callback(null, layer);
}); });
}); });
} };
function getRootNode (analysesResults, sourceId) { function getRootNode (analysesResults, sourceId) {
var node = _.find(analysesResults, function (a) { var node = _.find(analysesResults, function (a) {