change OBS_GetLegacyMetadata to return median/average measures too when called for polygons
This commit is contained in:
parent
71d891c067
commit
bcbd8a2be4
2
NEWS.md
2
NEWS.md
@ -5,6 +5,8 @@ __Improvements__
|
|||||||
* It is now possible to obtain measures that are averages or medians over
|
* It is now possible to obtain measures that are averages or medians over
|
||||||
arbitrary polygons ([#254](https://github.com/CartoDB/observatory-extension/pull/254).
|
arbitrary polygons ([#254](https://github.com/CartoDB/observatory-extension/pull/254).
|
||||||
* Added test point for Australian data
|
* Added test point for Australian data
|
||||||
|
* `OBS_GetLegacyMetadata` now returns median and averages in cases where it is
|
||||||
|
called for measures for polygons
|
||||||
|
|
||||||
1.3.0 (2017-01-17)
|
1.3.0 (2017-01-17)
|
||||||
|
|
||||||
|
@ -369,8 +369,10 @@ RETURNS TABLE (
|
|||||||
DECLARE
|
DECLARE
|
||||||
aggregate_condition TEXT DEFAULT '';
|
aggregate_condition TEXT DEFAULT '';
|
||||||
BEGIN
|
BEGIN
|
||||||
IF aggregate_type IS NOT NULL THEN
|
IF LOWER(aggregate_type) ILIKE 'sum' THEN
|
||||||
aggregate_condition := format(' AND numer_aggregate = %L ', aggregate_type);
|
aggregate_condition := ' AND numer_aggregate IN (''sum'', ''median'', ''average'') ';
|
||||||
|
ELSIF aggregate_type IS NOT NULL THEN
|
||||||
|
aggregate_condition := format(' AND numer_aggregate ILIKE %L ', aggregate_type);
|
||||||
END IF;
|
END IF;
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
EXECUTE format($string$
|
EXECUTE format($string$
|
||||||
|
@ -192,10 +192,16 @@ t
|
|||||||
_median_income_in_legacy_builder_metadata
|
_median_income_in_legacy_builder_metadata
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
_gini_in_legacy_builder_metadata
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
_total_pop_in_legacy_builder_metadata_sums
|
_total_pop_in_legacy_builder_metadata_sums
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
_median_income_not_in_legacy_builder_metadata_sums
|
_median_income_in_legacy_builder_metadata_sums
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
_gini_not_in_legacy_builder_metadata_sums
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
_no_dupe_subsections_in_legacy_builder_metadata
|
_no_dupe_subsections_in_legacy_builder_metadata
|
||||||
|
@ -499,15 +499,25 @@ SELECT 'us.census.acs.B19013001' IN (SELECT
|
|||||||
FROM cdb_observatory.OBS_LegacyBuilderMetadata()
|
FROM cdb_observatory.OBS_LegacyBuilderMetadata()
|
||||||
) AS _median_income_in_legacy_builder_metadata;
|
) AS _median_income_in_legacy_builder_metadata;
|
||||||
|
|
||||||
|
SELECT 'us.census.acs.B19083001' IN (SELECT
|
||||||
|
(jsonb_array_elements(((jsonb_array_elements(subsection))->'f1')->'columns')->'f1')->>'id' AS id
|
||||||
|
FROM cdb_observatory.OBS_LegacyBuilderMetadata()
|
||||||
|
) AS _gini_in_legacy_builder_metadata;
|
||||||
|
|
||||||
SELECT 'us.census.acs.B01003001' IN (SELECT
|
SELECT 'us.census.acs.B01003001' IN (SELECT
|
||||||
(jsonb_array_elements(((jsonb_array_elements(subsection))->'f1')->'columns')->'f1')->>'id' AS id
|
(jsonb_array_elements(((jsonb_array_elements(subsection))->'f1')->'columns')->'f1')->>'id' AS id
|
||||||
FROM cdb_observatory.OBS_LegacyBuilderMetadata('sum')
|
FROM cdb_observatory.OBS_LegacyBuilderMetadata('sum')
|
||||||
) AS _total_pop_in_legacy_builder_metadata_sums;
|
) AS _total_pop_in_legacy_builder_metadata_sums;
|
||||||
|
|
||||||
SELECT 'us.census.acs.B19013001' NOT IN (SELECT
|
SELECT 'us.census.acs.B19013001' IN (SELECT
|
||||||
(jsonb_array_elements(((jsonb_array_elements(subsection))->'f1')->'columns')->'f1')->>'id' AS id
|
(jsonb_array_elements(((jsonb_array_elements(subsection))->'f1')->'columns')->'f1')->>'id' AS id
|
||||||
FROM cdb_observatory.OBS_LegacyBuilderMetadata('sum')
|
FROM cdb_observatory.OBS_LegacyBuilderMetadata('sum')
|
||||||
) AS _median_income_not_in_legacy_builder_metadata_sums;
|
) AS _median_income_in_legacy_builder_metadata_sums;
|
||||||
|
|
||||||
|
SELECT 'us.census.acs.B19083001' NOT IN (SELECT
|
||||||
|
(jsonb_array_elements(((jsonb_array_elements(subsection))->'f1')->'columns')->'f1')->>'id' AS id
|
||||||
|
FROM cdb_observatory.OBS_LegacyBuilderMetadata('sum')
|
||||||
|
) AS _gini_not_in_legacy_builder_metadata_sums;
|
||||||
|
|
||||||
SELECT COUNT(*) = 0 _no_dupe_subsections_in_legacy_builder_metadata FROM (
|
SELECT COUNT(*) = 0 _no_dupe_subsections_in_legacy_builder_metadata FROM (
|
||||||
SELECT name, subsection, count(*) FROM
|
SELECT name, subsection, count(*) FROM
|
||||||
|
Loading…
Reference in New Issue
Block a user