Mercurial > gemma
view schema/updates/1316/01.search_for_bottleneck_id.sql @ 5721:0500d76e074b uploadwg
Fixed eraseObsoleteGaugesSQL by reintroducing matching on users CC.
The condition was removed when introducing file upload, but that leads
to too many gauges being removed.
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Fri, 19 Apr 2024 16:52:14 +0200 |
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; $$;