diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e951e91..fe611c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,8 +28,8 @@ Run the tests with `make test`. Update extension in a working database with: ``` -ALTER EXTENSION observatory VERSION TO 'current'; -ALTER EXTENSION observatory VERSION TO 'dev'; +ALTER EXTENSION observatory UPDATE TO 'current'; +ALTER EXTENSION observatory UPDATE TO 'dev'; ``` Note: we keep the current development version install as 'dev' always; diff --git a/NEWS.md b/NEWS.md index ee2f4f5..0c1c9f3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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) ------------------ diff --git a/src/pg/observatory.control b/src/pg/observatory.control index 84e7094..ee7a731 100644 --- a/src/pg/observatory.control +++ b/src/pg/observatory.control @@ -1,5 +1,5 @@ comment = 'CartoDB Observatory backend extension' -default_version = '1.8.0' +default_version = '1.9.0' requires = 'postgis' superuser = true schema = cdb_observatory diff --git a/src/pg/sql/42_observatory_exploration.sql b/src/pg/sql/42_observatory_exploration.sql index 272eec2..3a271d9 100644 --- a/src/pg/sql/42_observatory_exploration.sql +++ b/src/pg/sql/42_observatory_exploration.sql @@ -405,6 +405,13 @@ BEGIN END $$ LANGUAGE plpgsql; +DROP FUNCTION IF EXISTS cdb_observatory.OBS_GetAvailableTimespans( + bounds GEOMETRY, + filter_tags TEXT[], + numer_id TEXT, + denom_id TEXT, + geom_id TEXT +); CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableTimespans( bounds GEOMETRY DEFAULT NULL, filter_tags TEXT[] DEFAULT NULL, @@ -424,7 +431,9 @@ CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableTimespans( timespan_tags JSONB, valid_numer BOOLEAN, valid_denom BOOLEAN, - valid_geom BOOLEAN + valid_geom BOOLEAN, + timespan_alias TEXT, + timespan_range DATERANGE ) AS $$ DECLARE geom_clause TEXT; @@ -448,12 +457,14 @@ BEGIN NULL::TEXT timespan_aggregate, NULL::TEXT timespan_license, NULL::TEXT timespan_source, - NULL::TEXT timespan_type, + timespan_type::TEXT, NULL::JSONB timespan_extra, NULL::JSONB timespan_tags, - $1 = ANY(numers) valid_numer, - $2 = ANY(denoms) valid_denom, - $3 = ANY(geoms) valid_geom_id + COALESCE($1 = ANY(numers), false) valid_numer, + COALESCE($2 = ANY(denoms), false) valid_denom, + COALESCE($3 = ANY(geoms), false) valid_geom_id, + timespan_alias::TEXT, + timespan_range::DATERANGE FROM observatory.obs_meta_timespan WHERE %s (timespan_tags ?& $4 OR CARDINALITY($4) = 0) $string$, geom_clause)