# HG changeset patch # User Sascha Wilde # Date 1562253681 -7200 # Node ID 33180c25bd87c1b3e9cd60b3a9b45ed4134b8917 # Parent 1b11ff97c1d1de91a6bf116c77193257efa6c858 Added extra information to search results (wwname, ISRS code) I used the opportunity to unify the design of extra information on search results: the back end can provide optional additional information in dedicated keys (currently 'location' and 'location code'), formatting and rendering is done by the front end. diff -r 1b11ff97c1d1 -r 33180c25bd87 client/src/components/Search.vue --- a/client/src/components/Search.vue Thu Jul 04 16:30:19 2019 +0200 +++ b/client/src/components/Search.vue Thu Jul 04 17:21:21 2019 +0200 @@ -70,7 +70,12 @@ class="mr-1" fixed-width /> - {{ entry.name }} {{ entry.locationcode }} + {{ entry.name }} + ({{ entry.location + }}, {{ entry.locationcode }}) diff -r 1b11ff97c1d1 -r 33180c25bd87 schema/search_functions.sql --- a/schema/search_functions.sql Thu Jul 04 16:30:19 2019 +0200 +++ b/schema/search_functions.sql Thu Jul 04 17:21:21 2019 +0200 @@ -22,6 +22,7 @@ INTO _result FROM (SELECT (location_code).hectometre || ' rhm' AS name, isrs_asText(location_code) AS locationcode, + wwname AS location, ST_AsGeoJSON(geom)::json AS geom, 'rhm' AS type FROM waterway.distance_marks_virtual WHERE (location_code).hectometre = search_string::int) r; @@ -30,6 +31,7 @@ INTO _result FROM (SELECT (location_code).hectometre || ' rhm' AS name, isrs_asText(location_code) AS locationcode, + wwname AS location, ST_AsGeoJSON(geom)::json AS geom, 'rhm' AS type FROM waterway.distance_marks_virtual WHERE location_code = isrs_fromText(search_string)) r; @@ -66,7 +68,8 @@ BEGIN SELECT COALESCE(json_agg(r),'[]') INTO _result - FROM (SELECT name || ' (' || country_code || ')' AS name, + FROM (SELECT name, + country_code AS location, ST_AsGeoJSON(location)::json AS geom, 'city' AS type FROM waterway.geonames @@ -92,7 +95,8 @@ FROM ( SELECT objname AS name, ST_AsGeoJSON(geom)::json AS geom, - 'gauge' AS type + 'gauge' AS type, + isrs_asText(location) AS locationcode FROM waterway.gauges WHERE NOT erased AND location = isrs_fromText(search_string) ORDER BY name) r; @@ -102,7 +106,8 @@ FROM ( SELECT objname AS name, ST_AsGeoJSON(geom)::json AS geom, - 'gauge' AS type + 'gauge' AS type, + isrs_asText(location) AS locationcode FROM waterway.gauges WHERE NOT erased AND objname ILIKE '%' || search_string || '%' ORDER BY name) r; diff -r 1b11ff97c1d1 -r 33180c25bd87 schema/updates_3.0.1/02.search_functions.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates_3.0.1/02.search_functions.sql Thu Jul 04 17:21:21 2019 +0200 @@ -0,0 +1,1 @@ +../search_functions.sql \ No newline at end of file