Mercurial > gemma
view schema/updates/1316/01.search_for_bottleneck_id.sql @ 5560:f2204f91d286
Join the log lines of imports to the log exports to recover data from them.
Used in SR export to extract information that where in the meta json
but now are only found in the log.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 09 Feb 2022 18:34:40 +0100 |
parents | 7cbe5d32a614 |
children |
line wrap: on
line source
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, bottleneck_id AS location FROM waterway.bottlenecks WHERE (objnam ILIKE '%' || search_string || '%' OR bottleneck_id ILIKE '%' || search_string || '%') AND validity @> now() ORDER BY name) r; RETURN _result; END; $$;