Mercurial > gemma
annotate schema/updates/1006/01.fix-search-only-valid-bottleneck.sql @ 5082:c4ebb6ccc588 time-sliding
client: start a request for the last changed time on time slider
* initiate a refresh layers request when the time for the
finished request differs from the selected time on time slider
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Wed, 18 Mar 2020 14:11:44 +0100 |
parents | b10f210af325 |
children |
rev | line source |
---|---|
4021
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 CREATE OR REPLACE FUNCTION search_bottlenecks(search_string text) RETURNS jsonb |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
2 LANGUAGE plpgsql STABLE PARALLEL SAFE |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
3 AS $$ |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
4 DECLARE |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
5 _result jsonb; |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
6 BEGIN |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
7 SELECT COALESCE(json_agg(r),'[]') |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 INTO _result |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 FROM (SELECT objnam AS name, |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom, |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 'bottleneck' AS type |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
12 FROM waterway.bottlenecks |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
13 WHERE objnam ILIKE '%' || search_string || '%' |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 AND validity @> now() |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
15 ORDER BY name) r; |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 RETURN _result; |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
17 END; |
b10f210af325
Fixed latest fix to search-bottlenecks
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
18 $$; |