From d1a9dc0f24c9a3a9afbc85a22532b12b05850590 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 31 Oct 2019 21:00:28 +0100 Subject: [PATCH] use wikidata links for importance as well --- sql/functions.sql | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sql/functions.sql b/sql/functions.sql index e324277e..b2caf0a6 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -2698,13 +2698,15 @@ BEGIN RETURN result; END LOOP; - FOR match IN SELECT * FROM wikipedia_article - WHERE osm_type = osm_type and osm_id = osm_id - ORDER BY importance DESC limit 1 LOOP - result.importance := match.importance; - result.wikipedia := match.language || ':' || match.title; - RETURN result; - END LOOP; + IF extratags ? 'wikidata' THEN + FOR match IN SELECT * FROM wikipedia_article + WHERE wd_page_title = extratags->'wikidata' + ORDER BY importance DESC limit 1 LOOP + result.importance := match.importance; + result.wikipedia := match.language || ':' || match.title; + RETURN result; + END LOOP; + END IF; RETURN null; END; -- 2.39.5