Merge branch 'master' into dgaubert/ch78384/maps-api-replace-log4js-logger-by-pino

remotes/origin/dgaubert/ch78384/maps-api-replace-log4js-logger-by-pino
Daniel García Aubert 4 years ago
commit 74116523b4

@ -1,8 +1,16 @@
# Changelog
## 9.0.0
## 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
Breaking changes:
- Remove `/version` endpoint
- Drop support for Node.js < 12

@ -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"
},

@ -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();
}

@ -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);
});
});
});
});
Loading…
Cancel
Save