From 7ad8a993737b057f2b29a46d772b75bec18bf69e Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 23 May 2016 18:35:16 +0200 Subject: [PATCH] Unify getMapConfig signature for overviews adapter --- lib/cartodb/controllers/map.js | 3 ++- .../mapconfig/adapter/mapconfig-overviews-adapter.js | 3 ++- .../models/mapconfig/provider/named-map-provider.js | 4 ++-- test/integration/mapconfig_overviews_adapter.js | 10 ++++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 80150699..c573a298 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -182,7 +182,8 @@ MapController.prototype.create = function(req, res, prepareConfigFn) { function addOverviewsInformation(err, requestMapConfig, datasource) { assert.ifError(err); var next = this; - self.overviewsAdapter.getMapConfig(req.context.user, requestMapConfig, analysesResults, + context.analysesResults = analysesResults; + self.overviewsAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, function(err, requestMapConfig) { if (err) { return next(err); diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js b/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js index 9c2dc062..b8a473b5 100644 --- a/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js @@ -9,10 +9,11 @@ function MapConfigOverviewsAdapter(overviewsMetadataApi, filterStatsApi) { module.exports = MapConfigOverviewsAdapter; -MapConfigOverviewsAdapter.prototype.getMapConfig = function(user, requestMapConfig, analysesResults, callback) { +MapConfigOverviewsAdapter.prototype.getMapConfig = function(user, requestMapConfig, params, context, callback) { var self = this; var layers = requestMapConfig.layers; + var analysesResults = context.analysesResults; if (!layers || layers.length === 0) { return callback(null, requestMapConfig); diff --git a/lib/cartodb/models/mapconfig/provider/named-map-provider.js b/lib/cartodb/models/mapconfig/provider/named-map-provider.js index c9755fed..8597a07e 100644 --- a/lib/cartodb/models/mapconfig/provider/named-map-provider.js +++ b/lib/cartodb/models/mapconfig/provider/named-map-provider.js @@ -139,8 +139,8 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) { function addOverviewsInformation(err, _mapConfig, datasource) { assert.ifError(err); var next = this; - - self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, self.analysesResults, function(err, _mapConfig) { + context.analysesResults = self.analysesResults; + self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, function(err, _mapConfig) { if (err) { return next(err); } diff --git a/test/integration/mapconfig_overviews_adapter.js b/test/integration/mapconfig_overviews_adapter.js index 6444f18f..87a87935 100644 --- a/test/integration/mapconfig_overviews_adapter.js +++ b/test/integration/mapconfig_overviews_adapter.js @@ -37,7 +37,10 @@ describe('MapConfigOverviewsAdapter', function() { layers: [layer_without_overviews] }; - mapConfigOverviewsAdapter.getMapConfig('localhost', _mapConfig, [], function(err, mapConfig) { + var params = {}; + var context = {}; + + mapConfigOverviewsAdapter.getMapConfig('localhost', _mapConfig, params, context, function(err, mapConfig) { assert.ok(!err); var layers = mapConfig.layers; assert.equal(layers.length, 1); @@ -70,7 +73,10 @@ describe('MapConfigOverviewsAdapter', function() { layers: [layer_with_overviews] }; - mapConfigOverviewsAdapter.getMapConfig('localhost', _mapConfig, [], function(err, mapConfig) { + var params = {}; + var context = {}; + + mapConfigOverviewsAdapter.getMapConfig('localhost', _mapConfig, params, context, function(err, mapConfig) { assert.ok(!err); var layers = mapConfig.layers; assert.equal(layers.length, 1);