Put layergroupId handling close

This commit is contained in:
Raul Ochoa 2017-10-06 15:27:03 +02:00
parent 5d750f3b98
commit 64fe070ab2

View File

@ -130,7 +130,6 @@ TestClient.prototype.getWidget = function(widgetName, params, callback) {
url += '?' + qs.stringify({ filters: JSON.stringify(params.filters) }); url += '?' + qs.stringify({ filters: JSON.stringify(params.filters) });
} }
var layergroupId;
step( step(
function createLayergroup() { function createLayergroup() {
var next = this; var next = this;
@ -176,11 +175,12 @@ TestClient.prototype.getWidget = function(widgetName, params, callback) {
} }
); );
}, },
function getWidgetResult(err, _layergroupId) { function getWidgetResult(err, layergroupId) {
assert.ifError(err); assert.ifError(err);
var next = this; var next = this;
layergroupId = _layergroupId; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5;
var urlParams = { var urlParams = {
own_filter: params.hasOwnProperty('own_filter') ? params.own_filter : 1 own_filter: params.hasOwnProperty('own_filter') ? params.own_filter : 1
@ -217,8 +217,6 @@ TestClient.prototype.getWidget = function(widgetName, params, callback) {
); );
}, },
function finish(err, res) { function finish(err, res) {
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5;
var widget; var widget;
if (!err && res.body) { if (!err && res.body) {
widget = JSON.parse(res.body); widget = JSON.parse(res.body);
@ -241,7 +239,6 @@ TestClient.prototype.widgetSearch = function(widgetName, userQuery, params, call
url += '?' + qs.stringify({ filters: JSON.stringify(params.filters) }); url += '?' + qs.stringify({ filters: JSON.stringify(params.filters) });
} }
var layergroupId;
step( step(
function createLayergroup() { function createLayergroup() {
var next = this; var next = this;
@ -287,11 +284,12 @@ TestClient.prototype.widgetSearch = function(widgetName, userQuery, params, call
} }
); );
}, },
function getWidgetSearchResult(err, _layergroupId) { function getWidgetSearchResult(err, layergroupId) {
assert.ifError(err); assert.ifError(err);
var next = this; var next = this;
layergroupId = _layergroupId; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5;
var urlParams = { var urlParams = {
q: userQuery, q: userQuery,
@ -326,8 +324,6 @@ TestClient.prototype.widgetSearch = function(widgetName, userQuery, params, call
); );
}, },
function finish(err, res) { function finish(err, res) {
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5;
var searchResult; var searchResult;
if (!err && res.body) { if (!err && res.body) {
searchResult = JSON.parse(res.body); searchResult = JSON.parse(res.body);
@ -365,7 +361,6 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) {
} }
}; };
var layergroupId;
step( step(
function createLayergroup() { function createLayergroup() {
var next = this; var next = this;
@ -401,11 +396,10 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) {
} }
); );
}, },
function getDataviewResult(err, _layergroupId) { function getDataviewResult(err, layergroupId) {
assert.ifError(err); assert.ifError(err);
var next = this; var next = this;
layergroupId = _layergroupId;
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5; self.keysToDelete['user:localhost:mapviews:global'] = 5;
@ -644,11 +638,10 @@ TestClient.prototype.getTile = function(z, x, y, params, callback) {
} }
); );
}, },
function getTileResult(err, _layergroupId) { function getTileResult(err, layergroupId) {
// jshint maxcomplexity:12 // jshint maxcomplexity:12
assert.ifError(err); assert.ifError(err);
layergroupId = _layergroupId;
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5; self.keysToDelete['user:localhost:mapviews:global'] = 5;
@ -849,14 +842,13 @@ TestClient.prototype.getStaticCenter = function (params, callback) {
} }
); );
}, },
function getStaticResult(err, _layergroupid) { function getStaticResult(err, layergroupId) {
assert.ifError(err); assert.ifError(err);
layergroupid = _layergroupid; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupid).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5; self.keysToDelete['user:localhost:mapviews:global'] = 5;
url = `/api/v1/map/static/center/${layergroupid}/${z}/${lat}/${lng}/${width}/${height}.${format}`; url = `/api/v1/map/static/center/${layergroupId}/${z}/${lat}/${lng}/${width}/${height}.${format}`;
if (self.apiKey) { if (self.apiKey) {
url += '?' + qs.stringify({api_key: self.apiKey}); url += '?' + qs.stringify({api_key: self.apiKey});
@ -912,7 +904,6 @@ TestClient.prototype.getNodeStatus = function(nodeName, callback) {
url += '?' + qs.stringify({api_key: this.apiKey}); url += '?' + qs.stringify({api_key: this.apiKey});
} }
var layergroupId;
var nodes = {}; var nodes = {};
step( step(
function createLayergroup() { function createLayergroup() {
@ -951,10 +942,9 @@ TestClient.prototype.getNodeStatus = function(nodeName, callback) {
} }
); );
}, },
function getNodeStatusResult(err, _layergroupId) { function getNodeStatusResult(err, layergroupId) {
assert.ifError(err); assert.ifError(err);
layergroupId = _layergroupId;
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5; self.keysToDelete['user:localhost:mapviews:global'] = 5;
@ -1047,14 +1037,13 @@ TestClient.prototype.getAttributes = function(params, callback) {
} }
); );
}, },
function getAttributes(err, _layergroupid) { function getAttributes(err, layergroupId) {
assert.ifError(err); assert.ifError(err);
layergroupid = _layergroupid; self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupId).token] = 0;
self.keysToDelete['map_cfg|' + LayergroupToken.parse(layergroupid).token] = 0;
self.keysToDelete['user:localhost:mapviews:global'] = 5; self.keysToDelete['user:localhost:mapviews:global'] = 5;
url = `/api/v1/map/${layergroupid}/${params.layer}/attributes/${params.featureId}`; url = `/api/v1/map/${layergroupId}/${params.layer}/attributes/${params.featureId}`;
if (self.apiKey) { if (self.apiKey) {
url += '?' + qs.stringify({api_key: self.apiKey}); url += '?' + qs.stringify({api_key: self.apiKey});
@ -1126,7 +1115,7 @@ module.exports.getStaticMap = function getStaticMap(templateName, params, callba
// this could be removed once named maps are invalidated, otherwise you hits the cache // this could be removed once named maps are invalidated, otherwise you hits the cache
var server = new CartodbWindshaft(serverOptions); var server = new CartodbWindshaft(serverOptions);
assert.response(self.server, requestOptions, expectedResponse, function (res, err) { assert.response(server, requestOptions, expectedResponse, function (res, err) {
helper.deleteRedisKeys({'user:localhost:mapviews:global': 5}, function() { helper.deleteRedisKeys({'user:localhost:mapviews:global': 5}, function() {
return callback(err, mapnik.Image.fromBytes(new Buffer(res.body, 'binary'))); return callback(err, mapnik.Image.fromBytes(new Buffer(res.body, 'binary')));
}); });