diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-24 22:39:06 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-24 22:39:06 +0100 |
commit | e416118c8d023512b96de93960bdcc3ccb2e05b4 (patch) | |
tree | 8ed38991563895487fea4cb1d9d11511687ebae7 /web/lib | |
parent | 301079127471428fabb0504e40eaa33a4afc3525 (diff) | |
download | taginfo-e416118c8d023512b96de93960bdcc3ccb2e05b4.tar taginfo-e416118c8d023512b96de93960bdcc3ccb2e05b4.tar.gz |
Only ask for wikipages that could exist in key/values api call.
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/api/v4/key.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/web/lib/api/v4/key.rb b/web/lib/api/v4/key.rb index 08eb0d1..7150560 100644 --- a/web/lib/api/v4/key.rb +++ b/web/lib/api/v4/key.rb @@ -246,17 +246,22 @@ class Taginfo < Sinatra::Base paging(@ap). execute() + values_with_wiki_page = res.select{ |row| row['in_wiki'].to_i == 1 }.map{ |row| "'" + SQLite3::Database.quote(row['value']) + "'" }.join(',') + # Read description for tag from wikipages, first in English then in the chosen # language. This way the chosen language description will overwrite the default # English one. wikidesc = {} - ['en', lang].uniq.each do |lang| - @db.select('SELECT value, description FROM wiki.wikipages'). - condition('lang = ?', lang). - condition('key = ?', key). - condition("value IN (#{ res.map{ |row| "'" + SQLite3::Database.quote(row['value']) + "'" }.join(',') })"). - execute().each do |row| - wikidesc[row['value']] = row['description'] + + if values_with_wiki_page != '' + ['en', lang].uniq.each do |lang| + @db.select('SELECT value, description FROM wiki.wikipages'). + condition('lang = ?', lang). + condition('key = ?', key). + condition("value IN (#{ values_with_wiki_page })"). + execute().each do |row| + wikidesc[row['value']] = row['description'] + end end end |