From 02cb80daa181bc512ba00391ecd6741ec73632b5 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 23 May 2016 19:14:03 +0200 Subject: [PATCH] Use context for datasource 2/2 --- lib/cartodb/controllers/map.js | 38 +++--------------- .../mapconfig/provider/named-map-provider.js | 39 +++---------------- 2 files changed, 10 insertions(+), 67 deletions(-) diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index c3f698da..ecce9632 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -170,43 +170,15 @@ MapController.prototype.create = function(req, res, prepareConfigFn) { }, function beforeLayergroupCreate(err, requestMapConfig) { assert.ifError(err); - var next = this; - self.namedLayersAdapter.getMapConfig(user, requestMapConfig, req.params, context, - function(err, requestMapConfig, datasource) { - if (err) { - return next(err); - } - - return next(null, requestMapConfig, datasource); - } - ); + self.namedLayersAdapter.getMapConfig(user, requestMapConfig, req.params, context, this); }, - function addOverviewsInformation(err, requestMapConfig, datasource) { + function addOverviewsInformation(err, requestMapConfig) { assert.ifError(err); - var next = this; - self.overviewsAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, - function(err, requestMapConfig) { - if (err) { - return next(err); - } - - return next(null, requestMapConfig, datasource); - } - ); + self.overviewsAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, this); }, - function parseTurboCarto(err, requestMapConfig, datasource) { + function parseTurboCarto(err, requestMapConfig) { assert.ifError(err); - - var next = this; - self.turboCartoAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, - function (err, requestMapConfig) { - if (err) { - return next(err); - } - - return next(null, requestMapConfig, datasource); - } - ); + self.turboCartoAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, this); }, function createLayergroup(err, requestMapConfig) { assert.ifError(err); diff --git a/lib/cartodb/models/mapconfig/provider/named-map-provider.js b/lib/cartodb/models/mapconfig/provider/named-map-provider.js index 73298b98..67522669 100644 --- a/lib/cartodb/models/mapconfig/provider/named-map-provider.js +++ b/lib/cartodb/models/mapconfig/provider/named-map-provider.js @@ -56,7 +56,6 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) { var self = this; var mapConfig = null; - var datasource = null; var rendererParams; var apiKey; @@ -127,44 +126,16 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) { }, function prepareLayergroup(err, _mapConfig) { assert.ifError(err); - var next = this; self.analysesResults = context.analysesResults || []; - self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, - function(err, _mapConfig, datasource) { - if (err) { - return next(err); - } - - return next(null, _mapConfig, datasource); - } - ); + self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this); }, - function addOverviewsInformation(err, _mapConfig, datasource) { + function addOverviewsInformation(err, _mapConfig) { assert.ifError(err); - var next = this; - self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, - function(err, _mapConfig) { - if (err) { - return next(err); - } - - return next(null, _mapConfig, datasource); - } - ); + self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this); }, - function parseTurboCarto(err, _mapConfig, datasource) { + function parseTurboCarto(err, _mapConfig) { assert.ifError(err); - var next = this; - - self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, - function (err, _mapConfig) { - if (err) { - return next(err); - } - - return next(null, _mapConfig, datasource); - } - ); + self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this); }, function prepareContextLimits(err, _mapConfig) { assert.ifError(err);