From 6d9182aba8418f85c6c8864c922dc0efee824908 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 26 Oct 2015 13:42:06 +0100 Subject: [PATCH] Rename widgets endpoint to honour its name --- lib/cartodb/controllers/layergroup.js | 42 ++++----------------------- test/acceptance/histograms.js | 6 ++-- test/acceptance/lists.js | 2 +- 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index 3226ca6e..d5b1e05c 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -70,15 +70,11 @@ LayergroupController.prototype.register = function(app) { this.bbox.bind(this)); app.get(app.base_url_mapconfig + - '/:token/:layer/list/:listName', cors(), userMiddleware, - this.list.bind(this)); - - app.get(app.base_url_mapconfig + - '/:token/:layer/histogram/:histogramName', cors(), userMiddleware, - this.histogram.bind(this)); + '/:token/:layer/widget/:widgetName', cors(), userMiddleware, + this.widget.bind(this)); }; -LayergroupController.prototype.list = function(req, res) { +LayergroupController.prototype.widget = function(req, res) { var self = this; step( @@ -91,41 +87,13 @@ LayergroupController.prototype.list = function(req, res) { var mapConfigProvider = new MapStoreMapConfigProvider( self.mapStore, req.context.user, self.userLimitsApi, req.params ); - self.widgetBackend.getList(mapConfigProvider, req.params, this); + self.widgetBackend.getWidget(mapConfigProvider, req.params, this); }, function finish(err, tile, stats) { req.profiler.add(stats || {}); if (err) { - self.sendError(req, res, err, 'GET LIST'); - } else { - self.sendResponse(req, res, tile, 200); - } - } - ); - -}; - -LayergroupController.prototype.histogram = function(req, res) { - var self = this; - - step( - function setupParams() { - self.req2params(req, this); - }, - function retrieveList(err) { - assert.ifError(err); - - var mapConfigProvider = new MapStoreMapConfigProvider( - self.mapStore, req.context.user, self.userLimitsApi, req.params - ); - self.widgetBackend.getHistogram(mapConfigProvider, req.params, this); - }, - function finish(err, tile, stats) { - req.profiler.add(stats || {}); - - if (err) { - self.sendError(req, res, err, 'GET LIST'); + self.sendError(req, res, err, 'GET WIDGET'); } else { self.sendResponse(req, res, tile, 200); } diff --git a/test/acceptance/histograms.js b/test/acceptance/histograms.js index 8bb9da97..59cbdbde 100644 --- a/test/acceptance/histograms.js +++ b/test/acceptance/histograms.js @@ -83,7 +83,7 @@ describe('histograms', function() { assert.response(server, { - url: '/api/v1/map/' + layergroupId + '/0/histogram/pop_max', + url: '/api/v1/map/' + layergroupId + '/0/widget/pop_max', method: 'GET', headers: { host: 'localhost' @@ -100,7 +100,9 @@ describe('histograms', function() { return next(err); } - console.log(JSON.parse(res.body)); + var histogram = JSON.parse(res.body); + + assert.ok(histogram.length); next(null); } diff --git a/test/acceptance/lists.js b/test/acceptance/lists.js index 6c12ff2a..f22c20e0 100644 --- a/test/acceptance/lists.js +++ b/test/acceptance/lists.js @@ -83,7 +83,7 @@ describe('lists', function() { assert.response(server, { - url: '/api/v1/map/' + layergroupId + '/0/list/names', + url: '/api/v1/map/' + layergroupId + '/0/widget/names', method: 'GET', headers: { host: 'localhost'