Mercurial > gemma
changeset 4021:b10f210af325
Fixed latest fix to search-bottlenecks
The latest version did not use the current timestamp but the time of
function creation for comparison with the validity of BN -- thats
wrong of cause.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Mon, 22 Jul 2019 11:20:20 +0200 |
parents | e9fc97a29bd6 |
children | efe0904b1d45 1b6e1d79a0ca |
files | schema/search_functions.sql schema/updates/1006/01.fix-search-only-valid-bottleneck.sql schema/version.sql |
diffstat | 3 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/schema/search_functions.sql Mon Jul 22 11:06:37 2019 +0200 +++ b/schema/search_functions.sql Mon Jul 22 11:20:20 2019 +0200 @@ -55,7 +55,7 @@ 'bottleneck' AS type FROM waterway.bottlenecks WHERE objnam ILIKE '%' || search_string || '%' - AND validity @> 'now'::timestamptz + AND validity @> now() ORDER BY name) r; RETURN _result; END;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates/1006/01.fix-search-only-valid-bottleneck.sql Mon Jul 22 11:20:20 2019 +0200 @@ -0,0 +1,18 @@ +CREATE OR REPLACE FUNCTION search_bottlenecks(search_string text) RETURNS jsonb + LANGUAGE plpgsql STABLE PARALLEL SAFE + AS $$ +DECLARE + _result jsonb; +BEGIN + SELECT COALESCE(json_agg(r),'[]') + INTO _result + FROM (SELECT objnam AS name, + ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom, + 'bottleneck' AS type + FROM waterway.bottlenecks + WHERE objnam ILIKE '%' || search_string || '%' + AND validity @> now() + ORDER BY name) r; + RETURN _result; +END; +$$;