Merge pull request #324 from CartoDB/422-Refactor_GetAvailableTimespans

Refactor OBS_GetAvailableTimespans
This commit is contained in:
Mario de Frutos 2018-04-11 10:48:54 +02:00 committed by GitHub
commit 5ee349f4e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 550 additions and 536 deletions

View File

@ -28,8 +28,8 @@ Run the tests with `make test`.
Update extension in a working database with: Update extension in a working database with:
``` ```
ALTER EXTENSION observatory VERSION TO 'current'; ALTER EXTENSION observatory UPDATE TO 'current';
ALTER EXTENSION observatory VERSION TO 'dev'; ALTER EXTENSION observatory UPDATE TO 'dev';
``` ```
Note: we keep the current development version install as 'dev' always; Note: we keep the current development version install as 'dev' always;

View File

@ -1,3 +1,11 @@
1.9.0 (2018-02-14)
------------------
__Improvements__
* Improved `OBS_GetAvailableTimespans` for the DO Timespans project ([bigmetadata/#422](https://github.com/CartoDB/bigmetadata/issues/422))
* Fixed documentation
1.8.0 (2017-10-18) 1.8.0 (2017-10-18)
------------------ ------------------

View File

@ -1,5 +1,5 @@
comment = 'CartoDB Observatory backend extension' comment = 'CartoDB Observatory backend extension'
default_version = '1.8.0' default_version = '1.9.0'
requires = 'postgis' requires = 'postgis'
superuser = true superuser = true
schema = cdb_observatory schema = cdb_observatory

View File

@ -424,7 +424,9 @@ CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableTimespans(
timespan_tags JSONB, timespan_tags JSONB,
valid_numer BOOLEAN, valid_numer BOOLEAN,
valid_denom BOOLEAN, valid_denom BOOLEAN,
valid_geom BOOLEAN valid_geom BOOLEAN,
timespan_alias TEXT,
timespan_range DATERANGE
) AS $$ ) AS $$
DECLARE DECLARE
geom_clause TEXT; geom_clause TEXT;
@ -448,12 +450,14 @@ BEGIN
NULL::TEXT timespan_aggregate, NULL::TEXT timespan_aggregate,
NULL::TEXT timespan_license, NULL::TEXT timespan_license,
NULL::TEXT timespan_source, NULL::TEXT timespan_source,
NULL::TEXT timespan_type, timespan_type::TEXT,
NULL::JSONB timespan_extra, NULL::JSONB timespan_extra,
NULL::JSONB timespan_tags, NULL::JSONB timespan_tags,
$1 = ANY(numers) valid_numer, COALESCE($1 = ANY(numers), false) valid_numer,
$2 = ANY(denoms) valid_denom, COALESCE($2 = ANY(denoms), false) valid_denom,
$3 = ANY(geoms) valid_geom_id COALESCE($3 = ANY(geoms), false) valid_geom_id,
timespan_alias::TEXT,
timespan_range::DATERANGE
FROM observatory.obs_meta_timespan FROM observatory.obs_meta_timespan
WHERE %s (timespan_tags ?& $4 OR CARDINALITY($4) = 0) WHERE %s (timespan_tags ?& $4 OR CARDINALITY($4) = 0)
$string$, geom_clause) $string$, geom_clause)

File diff suppressed because one or more lines are too long