From bd8d147a7d511cacd162d1777cc8aea708312d33 Mon Sep 17 00:00:00 2001 From: Ivan Malagon Date: Wed, 6 Sep 2017 16:21:01 +0200 Subject: [PATCH 1/2] Fix out of range bug in date histograms --- lib/cartodb/models/dataview/histogram.js | 4 ++-- test/acceptance/dataviews/histogram.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/models/dataview/histogram.js b/lib/cartodb/models/dataview/histogram.js index c27c696f..6e62ad9d 100644 --- a/lib/cartodb/models/dataview/histogram.js +++ b/lib/cartodb/models/dataview/histogram.js @@ -198,8 +198,8 @@ var dateBasicsQueryTpl = dot.template([ var dateOverrideBasicsQueryTpl = dot.template([ '__cdb_basics AS (', ' SELECT', - ' max({{=it._end}}) AS __cdb_max_val,', - ' min({{=it._start}}) AS __cdb_min_val,', + ' max({{=it._end}})::float AS __cdb_max_val,', + ' min({{=it._start}})::float AS __cdb_min_val,', ' avg(date_part(\'epoch\', {{=it._column}})) AS __cdb_avg_val,', ' min(', ' date_trunc(', diff --git a/test/acceptance/dataviews/histogram.js b/test/acceptance/dataviews/histogram.js index 3baf002b..c9e16489 100644 --- a/test/acceptance/dataviews/histogram.js +++ b/test/acceptance/dataviews/histogram.js @@ -332,6 +332,21 @@ describe('histogram-dataview for date column type', function() { }); }); + it('should cast overridden start and end to float to avoid out of range errors ' + test.desc, function (done) { + var params = { + start: -2145916800, + end: 1009843199 + }; + + this.testClient = new TestClient(mapConfig, 1234); + this.testClient.getDataview(test.dataviewId, params, function (err, dataview) { + assert.ok(!err, err); + assert.equal(dataview.type, 'histogram'); + assert.ok(dataview.bin_width > 0, 'Unexpected bin width: ' + dataview.bin_width); + + done(); + }); + }); it('should return same histogram ' + test.desc, function (done) { var params = { From d77075295e1609ac1efed61dd255280d8a4bca69 Mon Sep 17 00:00:00 2001 From: Ivan Malagon Date: Thu, 7 Sep 2017 10:48:21 +0200 Subject: [PATCH 2/2] Update version and NEWS --- NEWS.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 62e7129c..45a7e000 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # Changelog +## 3.12.8 +Released 2017-mm-dd + +Bug fixes: +- Integer out of range in date histograms. (https://github.com/CartoDB/support/issues/962) + ## 3.12.7 Released 2017-09-01 diff --git a/package.json b/package.json index 058d0841..020438ee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "3.12.7", + "version": "3.12.8", "description": "A map tile server for CartoDB", "keywords": [ "cartodb"