Merge pull request #55 from ZeusWPI/better-chart

Better statistics
This commit is contained in:
Robbe Van Herck 2019-06-17 16:21:31 +02:00 committed by GitHub
commit 7c1aec2792
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,10 +10,16 @@ class Statistics < Rails::Application
end end
def shamehash def shamehash
none_shaming = total_debt + shameful_users.sum(:balance) debt_users = shameful_users.inject({}) do |h, u|
shameful_users.inject({'Reputable users' => none_shaming.to_f / total_debt}) do |h, u|
h.merge({u.name => - u.balance.to_f / total_debt * 100.0}) h.merge({u.name => - u.balance.to_f / total_debt * 100.0})
end end
.select { |key, value| value > 2 }
.transform_values! { |value| value.floor }
total_displayed_debt_pct = debt_users.values.inject(0) {|a,b| a+b}
debt_users["Other users"] = 100 - total_displayed_debt_pct
debt_users
end end
def by_issuer def by_issuer