diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-19 11:18:27 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-19 11:18:27 +0100 |
commit | 253b55a53212ea59cd188418ef138dcbbbaba718 (patch) | |
tree | a1e21869f4f471e59bab7c585acc486d4e65e075 /web/lib/ui | |
parent | 34bdd4c02b55047e2101219e58ef5131220ecb16 (diff) | |
download | taginfo-253b55a53212ea59cd188418ef138dcbbbaba718.tar taginfo-253b55a53212ea59cd188418ef138dcbbbaba718.tar.gz |
Add cool member role chart
Diffstat (limited to 'web/lib/ui')
-rw-r--r-- | web/lib/ui/relation.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/web/lib/ui/relation.rb b/web/lib/ui/relation.rb index 5801ae2..27a0ea1 100644 --- a/web/lib/ui/relation.rb +++ b/web/lib/ui/relation.rb @@ -30,6 +30,27 @@ class Taginfo < Sinatra::Base condition("rtype=?", rtype). get_first_value().to_i + sum_count_all = @db.select("SELECT members_all FROM db.relation_types WHERE rtype=?", @rtype).get_first_value().to_i + + @roles = [] + sum = { 'nodes' => 0, 'ways' => 0, 'relations' => 0 } + @db.select("SELECT * FROM db.relation_roles WHERE rtype=? ORDER BY count_all DESC", @rtype).execute() do |row| + %w( nodes ways relations ).each do |type| + count = row["count_#{ type }"] + if row['count_all'] < sum_count_all * 0.01 + sum[type] += count + else + @roles << { :role => row['role'], :type => type, :value => count } + end + end + end + if sum['nodes'] > 0 || sum['ways'] > 0 || sum['relations'] > 0 + %w( nodes ways relations ).each do |type| + @roles << { :role => '...', :type => type, :value => sum[type] } + end + end + + javascript 'd3/d3.v3.min' javascript "#{ r18n.locale.code }/relation" erb :relation end |