From 102e75ce955e0464aedbd6a47ceb23dd3351db68 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 31 Oct 2018 12:00:40 +0100 Subject: [PATCH 1/3] Add test for hours time dimension It tests the problem solved in #1054 --- test/acceptance/aggregation.js | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index d9924eee..47ae3c90 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -1344,6 +1344,73 @@ describe('aggregation', function () { }); }); + it.only('aggregation dimension hour iso format with timezone', function (done) { + this.mapConfig = createVectorMapConfig([ + { + type: 'cartodb', + options: { + // take two points per hour over two days + sql: pointsWithTimeSQL(96, '2018-01-01T00:00:00+02', '2018-01-01T23:59:59+02', 0), + dates_as_numbers: true, + aggregation: { + threshold: 1, + dimensions: { + hour: { + column: 'date', + group: { + units: 'hour', + timezone: '+7200' + }, + format: 'iso', + } + } + + } + } + } + ]); + + this.testClient = new TestClient(this.mapConfig); + const options = { + format: 'mvt' + }; + this.testClient.getTile(0, 0, 0, options, (err, res, tile) => { + if (err) { + return done(err); + } + const tileJSON = tile.toJSON(); + const resultHours = tileJSON[0].features.map(f => f.properties.hour).sort(); + assert.deepEqual(resultHours, [ + "2018-01-01T00", + "2018-01-01T01", + "2018-01-01T02", + "2018-01-01T03", + "2018-01-01T04", + "2018-01-01T05", + "2018-01-01T06", + "2018-01-01T07", + "2018-01-01T08", + "2018-01-01T09", + "2018-01-01T10", + "2018-01-01T11", + "2018-01-01T12", + "2018-01-01T13", + "2018-01-01T14", + "2018-01-01T15", + "2018-01-01T16", + "2018-01-01T17", + "2018-01-01T18", + "2018-01-01T19", + "2018-01-01T20", + "2018-01-01T21", + "2018-01-01T22", + "2018-01-01T23" + ]); + tileJSON[0].features.forEach(f => assert.equal(f.properties._cdb_feature_count, 4)); + done(); + }); + }); + ['centroid', 'point-sample', 'point-grid'].forEach(placement => { it(`dimensions should work for ${placement} placement`, function(done) { this.mapConfig = createVectorMapConfig([ From c63380427e95d6dbbf2ed3f5359634603724ca7b Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 31 Oct 2018 12:02:23 +0100 Subject: [PATCH 2/3] Fix comment --- test/acceptance/aggregation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 47ae3c90..5cf2a0d2 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -1349,7 +1349,7 @@ describe('aggregation', function () { { type: 'cartodb', options: { - // take two points per hour over two days + // take four points per hour over two days sql: pointsWithTimeSQL(96, '2018-01-01T00:00:00+02', '2018-01-01T23:59:59+02', 0), dates_as_numbers: true, aggregation: { From b0d1d5a07a54230c8ff5e15d72858d70e6ec76cf Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 31 Oct 2018 12:39:06 +0100 Subject: [PATCH 3/3] Fix test --- test/acceptance/aggregation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 5cf2a0d2..6ff81409 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -1344,7 +1344,7 @@ describe('aggregation', function () { }); }); - it.only('aggregation dimension hour iso format with timezone', function (done) { + it('aggregation dimension hour iso format with timezone', function (done) { this.mapConfig = createVectorMapConfig([ { type: 'cartodb',