diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-17 23:18:06 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-17 23:18:06 +0100 |
commit | 1bed7a359a16596925541574dc26feb5ae98275e (patch) | |
tree | 7ddc8aa7fc7938a84fc8c2108b9a0069b48d563d /web/lib | |
parent | 363579cf17fe54c5ffcd5407164ceaa6be8e16fe (diff) | |
download | taginfo-1bed7a359a16596925541574dc26feb5ae98275e.tar taginfo-1bed7a359a16596925541574dc26feb5ae98275e.tar.gz |
Fix fraction calculation in relations api
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/api/v4/relations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/web/lib/api/v4/relations.rb b/web/lib/api/v4/relations.rb index 143ee05..c84758d 100644 --- a/web/lib/api/v4/relations.rb +++ b/web/lib/api/v4/relations.rb @@ -36,7 +36,7 @@ class Taginfo < Sinatra::Base paging(@ap). execute() - all_relations = @db.stats('relations') + all_relations = @db.stats('relations').to_i prevroles = @db.select('SELECT rtype, role, count, fraction FROM db.prevalent_roles'). condition("rtype IN (#{ res.map{ |row| "'" + SQLite3::Database.quote(row['rtype']) + "'" }.join(',') })"). @@ -63,7 +63,7 @@ class Taginfo < Sinatra::Base :data => res.map{ |row| { :relation_type => row['rtype'], :count => row['count'].to_i, - :count_fraction => row['count'].to_i / all_relations, + :count_fraction => row['count'].to_f / all_relations, :prevalent_roles => row['members_all'] ? pr[row['rtype']][0,10] : nil } } }.to_json |