From c3ddb933bbc2c3068f18f1364682ae33e50dd0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 14 Mar 2018 13:10:24 +0100 Subject: [PATCH] Extract getStaticImageOptions middleware from controller's context --- lib/cartodb/controllers/named_maps.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index fe9b6bba..ed8ebd1f 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -80,7 +80,7 @@ NamedMapsController.prototype.register = function(app) { getAffectedTables(), getTemplate(staticOptions), prepareLayerFilterFromPreviewLayers(staticOptions), - this.getStaticImageOptions(), + getStaticImageOptions({ tablesExtentApi: this.tablesExtentApi }), this.getImage(staticOptions), this.incrementMapViews(), this.setSurrogateKey(), @@ -116,7 +116,7 @@ function getNamedMapProvider ({ namedMapProviderCache, label, forcedFormat = nul next(); }); }; -}; +} function getAffectedTables () { return function getAffectedTables (req, res, next) { @@ -134,7 +134,7 @@ function getAffectedTables () { next(); }); }; -}; +} function getTemplate ({ label }) { return function getTemplateMiddleware (req, res, next) { @@ -151,7 +151,7 @@ function getTemplate ({ label }) { next(); }); }; -}; +} function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label }) { return function prepareLayerFilterFromPreviewLayersMiddleware (req, res, next) { @@ -193,7 +193,7 @@ function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label }) next(); }); }; -}; +} function getTile ({ tileBackend, label }) { return function getTileMiddleware (req, res, next) { @@ -214,9 +214,9 @@ function getTile ({ tileBackend, label }) { next(); }); }; -}; +} -NamedMapsController.prototype.getStaticImageOptions = function () { +function getStaticImageOptions ({ tablesExtentApi }) { return function getStaticImageOptionsMiddleware(req, res, next) { const { user, namedMapProvider, template } = res.locals; @@ -240,7 +240,7 @@ NamedMapsController.prototype.getStaticImageOptions = function () { return next(); } - this.tablesExtentApi.getBounds(user, affectedTables, (err, bounds) => { + tablesExtentApi.getBounds(user, affectedTables, (err, bounds) => { if (err) { return next(); } @@ -250,8 +250,8 @@ NamedMapsController.prototype.getStaticImageOptions = function () { return next(); }); }); - }.bind(this); -}; + }; +} function getImageOptions (params, template) { const { zoom, lon, lat, bbox } = params;