commit
7c1aec2792
1 changed files with 8 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue