summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2011-10-10 16:05:30 +0200
committerJochen Topf <jochen@topf.org>2011-10-10 16:05:30 +0200
commit3ee5a07b907df9568a5b26093dbe7392886eb508 (patch)
tree6751a4c73e044f27bc4f6d56738c6adecabdab7b
parentcd7a6f5837545d255c5394684b42f8682ebc7154 (diff)
downloadtaginfo-3ee5a07b907df9568a5b26093dbe7392886eb508.tar
taginfo-3ee5a07b907df9568a5b26093dbe7392886eb508.tar.gz
Use .to_i == 1 instead of == '1'
Different Sqlite versions (or ruby sqlite driver versions) seem to return contents of integer columns in different ways. This should make it work in all versions.
-rw-r--r--web/lib/api/db.rb6
-rw-r--r--web/lib/api/wiki.rb8
-rw-r--r--web/lib/utils.rb4
-rwxr-xr-xweb/taginfo.rb2
4 files changed, 10 insertions, 10 deletions
diff --git a/web/lib/api/db.rb b/web/lib/api/db.rb
index 104b4dc..a977965 100644
--- a/web/lib/api/db.rb
+++ b/web/lib/api/db.rb
@@ -127,9 +127,9 @@ class Taginfo < Sinatra::Base
:count_relations_fraction => row['count_relations'].to_f / @db.stats('relations'),
:values_all => row['values_all'].to_i,
:users_all => row['users_all'].to_i,
- :in_wiki => row['in_wiki'] == '1' ? true : false,
- :in_josm => row['in_josm'] == '1' ? true : false,
- :in_potlatch => row['in_potlatch'] == '1' ? true : false,
+ :in_wiki => row['in_wiki'].to_i == 1 ? true : false,
+ :in_josm => row['in_josm'].to_i == 1 ? true : false,
+ :in_potlatch => row['in_potlatch'].to_i == 1 ? true : false,
}
h[:wikipages] = row['wikipages'] if row['wikipages']
h[:prevalent_values] = row['prevalent_values'][0,10] if row['prevalent_values']
diff --git a/web/lib/api/wiki.rb b/web/lib/api/wiki.rb
index d215937..7525428 100644
--- a/web/lib/api/wiki.rb
+++ b/web/lib/api/wiki.rb
@@ -9,10 +9,10 @@ class Taginfo < Sinatra::Base
:title => h(row['title']),
:description => h(row['description']),
:image => h(row['image']),
- :on_node => row['on_node'] == '1' ? true : false,
- :on_way => row['on_way'] == '1' ? true : false,
- :on_area => row['on_area'] == '1' ? true : false,
- :on_relation => row['on_relation'] == '1' ? true : false,
+ :on_node => row['on_node'].to_i == 1 ? true : false,
+ :on_way => row['on_way'].to_i == 1 ? true : false,
+ :on_area => row['on_area'].to_i == 1 ? true : false,
+ :on_relation => row['on_relation'].to_i == 1 ? true : false,
:tags_implies => row['tags_implies' ].split(','),
:tags_combination => row['tags_combination'].split(','),
:tags_linked => row['tags_linked' ].split(',')
diff --git a/web/lib/utils.rb b/web/lib/utils.rb
index 476d02b..90fa239 100644
--- a/web/lib/utils.rb
+++ b/web/lib/utils.rb
@@ -81,10 +81,10 @@ end
def tagcloud_color(tag)
c = 0xa0;
- if tag['in_wiki'] == '1'
+ if tag['in_wiki'].to_i == 1
c -= 0x40;
end
- if tag['in_josm'] == '1'
+ if tag['in_josm'].to_i == 1
c -= 0x60;
end
sprintf('#%02x%02x%02x', c, c, c)
diff --git a/web/taginfo.rb b/web/taginfo.rb
index cdcdc23..b6a017f 100755
--- a/web/taginfo.rb
+++ b/web/taginfo.rb
@@ -52,7 +52,7 @@ TAGCLOUD_NUMBER_OF_TAGS = 200
db = SQL::Database.new('../../data')
db.select('SELECT * FROM sources ORDER BY no').execute().each do |source|
- Source.new source['id'], source['name'], source['data_until'], source['update_start'], source['update_end'], source['visible'] == '1'
+ Source.new source['id'], source['name'], source['data_until'], source['update_start'], source['update_end'], source['visible'].to_i == 1
end
DATA_UNTIL = db.select("SELECT min(data_until) FROM sources").get_first_value().sub(/:..$/, '')