From 1bed7a359a16596925541574dc26feb5ae98275e Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 17 Jan 2013 23:18:06 +0100 Subject: Fix fraction calculation in relations api --- web/lib/api/v4/relations.rb | 4 ++-- 1 file 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 -- cgit v1.2.3