From a334668751ca122e0e34c77d297f60818e951df6 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Mon, 7 Jan 2013 15:47:05 +0100 Subject: Empty table issue cleanup. Sometimes there are not results for some query and you'll end up with an empty table. It would be nice if no empty table appears in this case but instead some nice message. But we can't simply remove the table, because if people use the search-inside-table function and that was the result of the empty table they loose the ability to change the search term. We could only draw the table in the first place if there will be something in it. But just finding out whether there will be something in the table can be quite expensive, for instance with searches for values. So we don't want to do this twice (once in the template to find out whether to draw the table in the first place and once in the API call filling the table.) So we are currently stuck with what we have until somebody invents a better way. --- web/lib/ui/keys_tags.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'web/lib') diff --git a/web/lib/ui/keys_tags.rb b/web/lib/ui/keys_tags.rb index 2685a5f..8c59e17 100644 --- a/web/lib/ui/keys_tags.rb +++ b/web/lib/ui/keys_tags.rb @@ -40,6 +40,7 @@ class Taginfo < Sinatra::Base @prevalent_values << { 'value' => '(other)', 'count' => @count_all_values - sum } end + @josm_count = @db.count('josm_style_rules').condition('k = ?', @key).get_first_value().to_i @wiki_count = @db.count('wiki.wikipages').condition('value IS NULL').condition('key=?', @key).get_first_value().to_i @user_count = @db.select('SELECT users_all FROM db.keys').condition('key=?', @key).get_first_value().to_i @@ -91,6 +92,7 @@ class Taginfo < Sinatra::Base @sel[@filter_type] = ' selected="selected"' @filter_xapi = { 'all' => '*', nil => '*', 'nodes' => 'node', 'ways' => 'way', 'relations' => 'relation' }[@filter_type]; + @josm_count = @db.count('josm_style_rules').condition('k = ?', @key).condition('v = ?', @value).get_first_value().to_i @wiki_count = @db.count('wiki.wikipages').condition('key=?', @key).condition('value=?', @value).get_first_value().to_i if @wiki_count == 0 @wiki_count_key = @db.count('wiki.wikipages').condition('key=?', @key).condition('value IS NULL').get_first_value().to_i -- cgit v1.2.3