From 4d7eb555a8432b4ddb2933a6b24df7efeb2be534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 5 Jun 2020 14:09:40 +0200 Subject: [PATCH 1/5] Update carto-package.json --- carto-package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/carto-package.json b/carto-package.json index 39d481eb..a94347a5 100644 --- a/carto-package.json +++ b/carto-package.json @@ -2,8 +2,8 @@ "name": "carto_windshaft", "current_version": { "requires": { - "node": "^10.15.1", - "npm": "^6.4.1", + "node": "^12.16.3", + "npm": "^6.14.4", "mapnik": "==3.0.15.16", "crankshaft": "~0.8.1" }, From a19e9a79b813ec7e38f887c7037e5aea46bf9c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 5 Jun 2020 14:10:24 +0200 Subject: [PATCH 2/5] Release 9.0.0 --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index b9551511..73ac9cbb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ # Changelog ## 9.0.0 -Released 2020-mm-dd +Released 2020-06-05 Breaking changes: - Remove `/version` endpoint From 9c21194c68654e2152d70a28cc9261b13a2035a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 9 Jun 2020 12:21:47 +0200 Subject: [PATCH 3/5] Set cache buster equal to 0 when there is no affected tables in the mapconfig --- lib/api/middlewares/last-updated-time-layergroup.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api/middlewares/last-updated-time-layergroup.js b/lib/api/middlewares/last-updated-time-layergroup.js index 1c4a3cab..63c4dac5 100644 --- a/lib/api/middlewares/last-updated-time-layergroup.js +++ b/lib/api/middlewares/last-updated-time-layergroup.js @@ -11,6 +11,10 @@ module.exports = function setLastUpdatedTimeToLayergroup () { } if (!affectedTables) { + res.locals.cache_buster = 0; + layergroup.layergroupid = `${layergroup.layergroupid}:${res.locals.cache_buster}`; + layergroup.last_updated = new Date(res.locals.cache_buster).toISOString(); + return next(); } From f235dcdeda9394fb8de195d537bf5ab9f376e920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 9 Jun 2020 13:05:39 +0200 Subject: [PATCH 4/5] Add test --- test/acceptance/layergroupid-test.js | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/acceptance/layergroupid-test.js diff --git a/test/acceptance/layergroupid-test.js b/test/acceptance/layergroupid-test.js new file mode 100644 index 00000000..2cb8d2ca --- /dev/null +++ b/test/acceptance/layergroupid-test.js @@ -0,0 +1,66 @@ +'use strict'; + +require('../support/test-helper'); + +const assert = require('../support/assert'); +const TestClient = require('../support/test-client'); +const { parse: parseLayergroupToken } = require('../../lib/models/layergroup-token'); + +describe('layergroup id', function () { + const suites = [ + { + description: 'with empty layers should respond with cache buster equal to 0', + expectedCacheBuster: '0', + mapConfig: { + version: '1.8.0', + layers: [] + } + }, + { + description: 'with layer and dumb query (no affected tables) should respond with cache buster equal to 0', + expectedCacheBuster: '0', + mapConfig: { + version: '1.8.0', + layers: [{ + type: 'cartodb', + options: { + sql: TestClient.SQL.ONE_POINT + } + }] + } + }, + { + description: 'with layer and legit query should respond with cache buster', + expectedCacheBuster: '1234567890123', + mapConfig: { + version: '1.8.0', + layers: [{ + type: 'cartodb', + options: { + sql: 'SELECT * FROM test_table' + } + }] + } + } + ]; + + suites.forEach(({ description, expectedCacheBuster, mapConfig }) => { + it(description, function (done) { + const testClient = new TestClient(mapConfig); + + testClient.getLayergroup((err, body) => { + if (err) { + return done(err); + } + + const { layergroupid } = body; + assert.ok(typeof layergroupid === 'string'); + + const { cacheBuster } = parseLayergroupToken(layergroupid); + assert.strictEqual(cacheBuster, expectedCacheBuster); + + testClient.drain(done); + }); + }); + }); +}); From 23839f5b4aeba5d8d40c7f2c2ae1040e528dca84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 9 Jun 2020 15:00:53 +0200 Subject: [PATCH 5/5] Update NEWS --- NEWS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.md b/NEWS.md index 73ac9cbb..54a883ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,13 @@ # Changelog +## 9.0.1 +Released 2020-mm-dd + +Bug Fixes: +- While instantiating a map, set the `cache buster` equal to `0` when there are no affected tables in the MapConfig. Thus `layergroupid` has the same structure always: + - `${map_id}:${cache_buster}` for anonymous map + - `${user}@${template_hash}@${map_id}:${cache_buster}` for named map + ## 9.0.0 Released 2020-06-05