commit
e5e0b39595
7
NEWS.md
7
NEWS.md
@ -1,3 +1,10 @@
|
|||||||
|
1.1.4 (2016-11-21)
|
||||||
|
|
||||||
|
__Bugfixes__
|
||||||
|
|
||||||
|
* Fix duplicate subsections with only a partial set of measures appearing from
|
||||||
|
`OBS_GetLegacyMetadata` ([#216](https://github.com/CartoDB/observatory-extension/issues/216)).
|
||||||
|
|
||||||
1.1.3 (2016-11-15)
|
1.1.3 (2016-11-15)
|
||||||
|
|
||||||
* Temporarily ignore EU data for the sake of testing
|
* Temporarily ignore EU data for the sake of testing
|
||||||
|
2604
release/observatory--1.1.4.sql
Normal file
2604
release/observatory--1.1.4.sql
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
comment = 'CartoDB Observatory backend extension'
|
comment = 'CartoDB Observatory backend extension'
|
||||||
default_version = '1.1.3'
|
default_version = '1.1.4'
|
||||||
requires = 'postgis, postgres_fdw'
|
requires = 'postgis, postgres_fdw'
|
||||||
superuser = true
|
superuser = true
|
||||||
schema = cdb_observatory
|
schema = cdb_observatory
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
comment = 'CartoDB Observatory backend extension'
|
comment = 'CartoDB Observatory backend extension'
|
||||||
default_version = '1.1.3'
|
default_version = '1.1.4'
|
||||||
requires = 'postgis, postgres_fdw'
|
requires = 'postgis, postgres_fdw'
|
||||||
superuser = true
|
superuser = true
|
||||||
schema = cdb_observatory
|
schema = cdb_observatory
|
||||||
|
@ -374,41 +374,39 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
EXECUTE format($string$
|
EXECUTE format($string$
|
||||||
WITH expanded_subsections AS (
|
WITH expanded AS (
|
||||||
SELECT numer_id,
|
SELECT JSONB_Build_Object('id', numer_id, 'name', numer_name) "column",
|
||||||
numer_name,
|
SUBSTR((sections).key, 9) section_id, (sections).value section_name,
|
||||||
numer_tags,
|
SUBSTR((subsections).key, 12) subsection_id, (subsections).value subsection_name
|
||||||
jsonb_each_text(numer_tags) as subsection_tag_id_name
|
FROM (
|
||||||
FROM cdb_observatory.OBS_GetAvailableNumerators()
|
SELECT numer_id, numer_name,
|
||||||
WHERE numer_weight > 0 %s
|
jsonb_each_text(numer_tags) as sections,
|
||||||
), expanded_sections AS (
|
jsonb_each_text as subsections
|
||||||
SELECT JSONB_Agg(JSONB_Build_Object(
|
FROM (SELECT numer_id, numer_name, numer_tags,
|
||||||
'f1', JSONB_Build_Object('id', numer_id, 'name', numer_name))) columns,
|
jsonb_each_text(numer_tags)
|
||||||
SUBSTR((subsection_tag_id_name).key, 12) subsection_id,
|
FROM cdb_observatory.obs_getavailablenumerators()
|
||||||
(subsection_tag_id_name).value subsection_name,
|
WHERE numer_weight > 0 %s
|
||||||
jsonb_each_text(numer_tags) as section_tag_id_name
|
) foo
|
||||||
FROM expanded_subsections
|
) bar
|
||||||
WHERE (subsection_tag_id_name).key LIKE 'subsection/%%'
|
WHERE (sections).key LIKE 'section/%%'
|
||||||
GROUP BY (subsection_tag_id_name).key, (subsection_tag_id_name).value,
|
AND (subsections).key LIKE 'subsection/%%'
|
||||||
numer_tags
|
), grouped_by_subsections AS (
|
||||||
), full_expansion AS (
|
SELECT JSONB_Agg(JSONB_Build_Object('f1', "column")) AS columns,
|
||||||
SELECT columns, subsection_id, subsection_name,
|
section_id, section_name, subsection_id, subsection_name
|
||||||
SUBSTR((section_tag_id_name).key, 9) section_id,
|
FROM expanded
|
||||||
(section_tag_id_name).value section_name
|
GROUP BY section_id, section_name, subsection_id, subsection_name
|
||||||
FROM expanded_sections
|
|
||||||
WHERE (section_tag_id_name).key LIKE 'section/%%'
|
|
||||||
)
|
|
||||||
SELECT section_name AS name, JSONB_Agg(
|
|
||||||
JSONB_Build_Object(
|
|
||||||
'f1', JSONB_Build_Object(
|
|
||||||
'name', subsection_name,
|
|
||||||
'id', subsection_id,
|
|
||||||
'columns', columns
|
|
||||||
)
|
)
|
||||||
)
|
SELECT section_name as name, JSONB_Agg(
|
||||||
) as subsection
|
JSONB_Build_Object(
|
||||||
FROM full_expansion
|
'f1', JSONB_Build_Object(
|
||||||
GROUP BY section_name
|
'name', subsection_name,
|
||||||
|
'id', subsection_id,
|
||||||
|
'columns', columns
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) as subsection
|
||||||
|
FROM grouped_by_subsections
|
||||||
|
GROUP BY section_name
|
||||||
$string$, aggregate_condition);
|
$string$, aggregate_condition);
|
||||||
RETURN;
|
RETURN;
|
||||||
END
|
END
|
||||||
|
@ -198,3 +198,6 @@ t
|
|||||||
_median_income_not_in_legacy_builder_metadata_sums
|
_median_income_not_in_legacy_builder_metadata_sums
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
_no_dupe_subsections_in_legacy_builder_metadata
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
@ -494,3 +494,12 @@ SELECT 'us.census.acs.B19013001' NOT 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_not_in_legacy_builder_metadata_sums;
|
||||||
|
|
||||||
|
SELECT COUNT(*) = 0 _no_dupe_subsections_in_legacy_builder_metadata FROM (
|
||||||
|
SELECT name, subsection, count(*) FROM
|
||||||
|
(SELECT name, ((JSONB_Array_Elements(subsection))->'f1')->>'id' subsection
|
||||||
|
FROM cdb_observatory.obs_legacybuildermetadata()) foo
|
||||||
|
GROUP BY name, subsection
|
||||||
|
HAVING count(*) > 1
|
||||||
|
) bar;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user