Pass tests
This commit is contained in:
@@ -1,23 +1,20 @@
|
||||
const AggregationMapConfig = require('../../aggregation/aggregation-mapconfig');
|
||||
const dateWrapper = require('../../../utils/date-wrapper');
|
||||
const queryUtils = require('../../../utils/query-utils');
|
||||
const dateWrapper = require('../../../utils/date-wrapper');
|
||||
|
||||
// Generate query to detect time columns
|
||||
// For every column cast to unix timestamp
|
||||
module.exports = class VectorMapConfigAdapter {
|
||||
/**
|
||||
* This middleware wraps the layer query transforming the date fields into numbers because mvt tiles
|
||||
* doesnt support dates as primitive type.
|
||||
*
|
||||
* - This middleware is ONLY activated when the `dates_as_numbers` option is enabled for some layer in the mapConfig.
|
||||
* - TODO: We currently support one single layer and we should define what to do with multiple layers.
|
||||
*/
|
||||
class VectorMapConfigAdapter {
|
||||
constructor(pgConnection) {
|
||||
this.pgConnection = pgConnection;
|
||||
}
|
||||
|
||||
getMapConfig(user, requestMapConfig, params, context, callback) {
|
||||
let mapConfig;
|
||||
try {
|
||||
mapConfig = new AggregationMapConfig(user, requestMapConfig, this.pgConnection);
|
||||
} catch (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!mapConfig.isVectorOnlyMapConfig()) {
|
||||
if (!this._isDatesAsNumbersFlagEnabled(requestMapConfig)) {
|
||||
return callback(null, requestMapConfig);
|
||||
}
|
||||
|
||||
@@ -25,7 +22,6 @@ module.exports = class VectorMapConfigAdapter {
|
||||
return callback(new Error('Get column types for multiple vector layers is not implemented'));
|
||||
}
|
||||
|
||||
|
||||
this._wrapDates(requestMapConfig, user)
|
||||
.then(updatedRequestMapConfig => callback(null, updatedRequestMapConfig))
|
||||
.catch(callback);
|
||||
@@ -55,4 +51,11 @@ module.exports = class VectorMapConfigAdapter {
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_isDatesAsNumbersFlagEnabled(requestMapConfig) {
|
||||
return requestMapConfig.layers.some(layer => layer.options.dates_as_numbers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = VectorMapConfigAdapter;
|
||||
@@ -3,7 +3,7 @@ const assert = require('assert');
|
||||
const TestClient = require('../support/test-client');
|
||||
const mapConfigFactory = require('../fixtures/test_mapconfigFactory');
|
||||
|
||||
describe.only('date-wrapping', () => {
|
||||
describe('date-wrapping', () => {
|
||||
let testClient;
|
||||
|
||||
describe('when a map instantiation has the "dates_as_numbers" option enabled', () => {
|
||||
|
||||
Reference in New Issue
Block a user