From bc7a5562977ce4e9f7da6fb7e2969d1c17c9bb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Fri, 26 Jan 2018 12:37:10 +0100 Subject: [PATCH 1/4] removing category cast to string in aggregation --- lib/cartodb/models/dataview/aggregation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/models/dataview/aggregation.js b/lib/cartodb/models/dataview/aggregation.js index 40774353..9b5d62ef 100644 --- a/lib/cartodb/models/dataview/aggregation.js +++ b/lib/cartodb/models/dataview/aggregation.js @@ -74,7 +74,7 @@ const specialNumericValuesColumns = () => `, nans_count, infinities_count`; const rankedAggregationQueryTpl = ctx => ` SELECT - CAST(category AS text), + category, value, false as agg, nulls_count, @@ -109,7 +109,7 @@ const rankedAggregationQueryTpl = ctx => ` const aggregationQueryTpl = ctx => ` SELECT - CAST(${ctx.column} AS text) AS category, + ${ctx.column} AS category, ${ctx.aggregationFn} AS value, false as agg, nulls_count, From 99421b613c106b916adf5efa4aac06ffe56db657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Fri, 26 Jan 2018 15:24:21 +0100 Subject: [PATCH 2/4] moving 'other' outside of the query allowing queries of different types --- lib/cartodb/models/dataview/aggregation.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/models/dataview/aggregation.js b/lib/cartodb/models/dataview/aggregation.js index 9b5d62ef..dbdb4277 100644 --- a/lib/cartodb/models/dataview/aggregation.js +++ b/lib/cartodb/models/dataview/aggregation.js @@ -87,7 +87,7 @@ const rankedAggregationQueryTpl = ctx => ` WHERE rank < ${ctx.limit} UNION ALL SELECT - 'Other' category, + null category, ${ctx.aggregation !== 'count' ? ctx.aggregation : 'sum'}(value) as value, true as agg, nulls_count, @@ -282,7 +282,7 @@ module.exports = class Aggregation extends BaseDataview { max_val = 0, categories_count = 0 } = result.rows[0] || {}; - + return { aggregation: this.aggregation, count: count, @@ -292,7 +292,13 @@ module.exports = class Aggregation extends BaseDataview { min: min_val, max: max_val, categoriesCount: categories_count, - categories: result.rows.map(({ category, value, agg }) => ({ category, value, agg })) + categories: result.rows.map(({ category, value, agg }) => { + return { + category: agg ? 'Others' : category, + value, + agg + }; + }) }; } From 8c839e214d9e0be13cb85f1680315e5e15673617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Fri, 26 Jan 2018 15:44:21 +0100 Subject: [PATCH 3/4] changing the value of string --- lib/cartodb/models/dataview/aggregation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cartodb/models/dataview/aggregation.js b/lib/cartodb/models/dataview/aggregation.js index dbdb4277..d4d1baf5 100644 --- a/lib/cartodb/models/dataview/aggregation.js +++ b/lib/cartodb/models/dataview/aggregation.js @@ -294,7 +294,7 @@ module.exports = class Aggregation extends BaseDataview { categoriesCount: categories_count, categories: result.rows.map(({ category, value, agg }) => { return { - category: agg ? 'Others' : category, + category: agg ? 'Other' : category, value, agg }; From 6f4e338dcbce2290f09e16b28e5158d5e727117b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Mon, 29 Jan 2018 15:19:07 +0100 Subject: [PATCH 4/4] version 5.0.0 --- NEWS.md | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6569f3e7..aee22f64 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,10 @@ # Changelog -## 4.8.1 -Released 2018-mm-dd +## 5.0.0 +Released 2018-01-29 +Backward incompatible changes: +- Aggregation dataview returns categories with the same type as the database type. For example, if we are aggretating by a numeric field, the resulting JSON will contain a number instead of a stringified number. ## 4.8.0 Released 2018-01-04 diff --git a/package.json b/package.json index e500a253..2ac978e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "4.8.1", + "version": "5.0.0", "description": "A map tile server for CartoDB", "keywords": [ "cartodb"