From 6c98f14c649eef1b46467285743bec54e88cdc05 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 5 Jul 2016 11:26:52 +0200 Subject: [PATCH] Return full list of nodes in response metadata --- NEWS.md | 3 +++ lib/cartodb/controllers/map.js | 4 ++-- test/acceptance/analysis/analysis-layers.js | 2 +- test/acceptance/analysis/named-maps.js | 2 +- test/acceptance/analysis/regressions.js | 7 +++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 93efa9df..0ee7c017 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ Released 2016-mm-dd +Bug fixes: + - Return full list of nodes in response metadata. + ## 2.57.0 diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 9a9015da..57165447 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -330,7 +330,7 @@ function getLastUpdatedTime(analysesResults, lastUpdateTime) { return lastUpdateTime; } return analysesResults.reduce(function(lastUpdateTime, analysis) { - return analysis.getSortedNodes().reduce(function(lastNodeUpdatedAtTime, node) { + return analysis.getNodes().reduce(function(lastNodeUpdatedAtTime, node) { var nodeUpdatedAtDate = node.getUpdatedAt(); var nodeUpdatedTimeAt = (nodeUpdatedAtDate && nodeUpdatedAtDate.getTime()) || 0; return nodeUpdatedTimeAt > lastNodeUpdatedAtTime ? nodeUpdatedTimeAt : lastNodeUpdatedAtTime; @@ -344,7 +344,7 @@ function addAnalysesMetadata(username, layergroup, analysesResults, includeQuery layergroup.metadata.analyses = []; analysesResults.forEach(function(analysis) { - var nodes = analysis.getSortedNodes(); + var nodes = analysis.getNodes(); layergroup.metadata.analyses.push({ nodes: nodes.reduce(function(nodesIdMap, node) { if (node.params.id) { diff --git a/test/acceptance/analysis/analysis-layers.js b/test/acceptance/analysis/analysis-layers.js index a19128b0..a745fb97 100644 --- a/test/acceptance/analysis/analysis-layers.js +++ b/test/acceptance/analysis/analysis-layers.js @@ -202,7 +202,7 @@ describe('analysis-layers', function() { assert.equal(analyses.length, 1, 'Invalid number of analyses in metadata'); var nodes = analyses[0].nodes; var nodesIds = Object.keys(nodes); - assert.deepEqual(nodesIds, ['2570e105-7b37-40d2-bdf4-1af889598745', 'HEAD']); + assert.deepEqual(nodesIds, ['HEAD', '2570e105-7b37-40d2-bdf4-1af889598745']); nodesIds.forEach(function(nodeId) { var node = nodes[nodeId]; assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node'); diff --git a/test/acceptance/analysis/named-maps.js b/test/acceptance/analysis/named-maps.js index bab87ee4..ca27ec37 100644 --- a/test/acceptance/analysis/named-maps.js +++ b/test/acceptance/analysis/named-maps.js @@ -141,7 +141,7 @@ describe('named-maps analysis', function() { assert.equal(analyses.length, 1, 'Invalid number of analyses in metadata'); var nodes = analyses[0].nodes; var nodesIds = Object.keys(nodes); - assert.deepEqual(nodesIds, ['2570e105-7b37-40d2-bdf4-1af889598745', 'HEAD']); + assert.deepEqual(nodesIds, ['HEAD', '2570e105-7b37-40d2-bdf4-1af889598745']); nodesIds.forEach(function(nodeId) { var node = nodes[nodeId]; assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node'); diff --git a/test/acceptance/analysis/regressions.js b/test/acceptance/analysis/regressions.js index 2db8d931..a41eb10b 100644 --- a/test/acceptance/analysis/regressions.js +++ b/test/acceptance/analysis/regressions.js @@ -100,10 +100,13 @@ describe('analysis-layers regressions', function() { assert.equal(analyses.length, 1); var expectedIds = ['customer_home_locations', 'b0', 'b1', 'a2', 'a3', 'a4']; - assert.equal(Object.keys(analyses[0].nodes).length, expectedIds.length, Object.keys(analyses[0].nodes)); expectedIds.forEach(function(expectedId) { - analyses[0].nodes.hasOwnProperty(expectedId); + assert.ok( + analyses[0].nodes.hasOwnProperty(expectedId), + 'Missing "' + expectedId + '" from node list.' + ); }); + assert.equal(Object.keys(analyses[0].nodes).length, expectedIds.length, Object.keys(analyses[0].nodes)); testClient.drain(done); });