If we have the stats FF disbabled return empty array instead of null
But we keep checking for elements in the returned object because we don't want to include the stats property if the FF is disabled
This commit is contained in:
parent
d471905358
commit
440953b1cd
@ -11,6 +11,6 @@ StatsBackend.prototype.getStats = function(mapConfig, dbConnection, callback) {
|
|||||||
if (layerStatsEnabled) {
|
if (layerStatsEnabled) {
|
||||||
layerStats().getStats(mapConfig, dbConnection, callback);
|
layerStats().getStats(mapConfig, dbConnection, callback);
|
||||||
} else {
|
} else {
|
||||||
return callback(null, null);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -368,7 +368,7 @@ function(req, res, mapconfig, layergroup, analysesResults, callback) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (layersStats) {
|
if (layersStats.length > 0) {
|
||||||
layergroup.metadata.layers.forEach(function (layer, index) {
|
layergroup.metadata.layers.forEach(function (layer, index) {
|
||||||
layer.meta.stats = layersStats[index];
|
layer.meta.stats = layersStats[index];
|
||||||
});
|
});
|
||||||
|
@ -5,14 +5,11 @@ var TestClient = require('../../support/test-client');
|
|||||||
|
|
||||||
describe('Create mapnik layergroup', function() {
|
describe('Create mapnik layergroup', function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
this.layerMetadataConfig = global.environment.enabledFeatures.layerMetadata;
|
|
||||||
this.layerStatsConfig = global.environment.enabledFeatures.layerStats;
|
this.layerStatsConfig = global.environment.enabledFeatures.layerStats;
|
||||||
global.environment.enabledFeatures.layerMetadata = true;
|
|
||||||
global.environment.enabledFeatures.layerStats = true;
|
global.environment.enabledFeatures.layerStats = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
global.environment.enabledFeatures.layerMetadata = this.layerMetadataConfig;
|
|
||||||
global.environment.enabledFeatures.layerStats = this.layerStatsConfig;
|
global.environment.enabledFeatures.layerStats = this.layerStatsConfig;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -255,4 +252,28 @@ describe('Create mapnik layergroup', function() {
|
|||||||
testClient.drain(done);
|
testClient.drain(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not include the stats part if the FF is disabled', function(done) {
|
||||||
|
global.environment.enabledFeatures.layerStats = false;
|
||||||
|
var testClient = new TestClient({
|
||||||
|
version: '1.4.0',
|
||||||
|
layers: [
|
||||||
|
httpLayer,
|
||||||
|
mapnikLayer1,
|
||||||
|
httpLayer
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
testClient.getLayergroup(function(err, layergroup) {
|
||||||
|
assert.ok(!err);
|
||||||
|
assert.equal(layergroup.metadata.layers[0].id, typeLayerId('http', 0));
|
||||||
|
assert.equal(layergroup.metadata.layers[0].type, 'http');
|
||||||
|
assert.equal(layergroup.metadata.layers[1].id, mapnikBasicLayerId(0));
|
||||||
|
assert.equal(layergroup.metadata.layers[1].type, 'mapnik');
|
||||||
|
assert.ok(!layergroup.metadata.layers[1].meta.hasOwnProperty('stats'));
|
||||||
|
assert.equal(layergroup.metadata.layers[2].id, typeLayerId('http', 1));
|
||||||
|
assert.equal(layergroup.metadata.layers[2].type, 'http');
|
||||||
|
testClient.drain(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user