2015-09-11 18:04:45 +02:00
|
|
|
|
|
|
|
class Statistics < Rails::Application
|
|
|
|
|
|
|
|
def shameful_users
|
|
|
|
User.where('balance > :amount', amount: config.shameful_balance)
|
2015-09-11 23:32:38 +02:00
|
|
|
.order(balance: :desc)
|
|
|
|
end
|
|
|
|
|
|
|
|
def total_debt
|
|
|
|
User.where.not(id: User.zeus).where('balance > 0').sum(:balance)
|
2015-09-11 18:04:45 +02:00
|
|
|
end
|
|
|
|
|
2015-09-12 00:17:43 +02:00
|
|
|
def shamehash
|
|
|
|
none_shaming = shameful_users.sum(:balance)
|
|
|
|
shameful_users.inject({'None-shameful users' => none_shaming}) do |h, u|
|
|
|
|
h.merge({u.name => u.balance})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-11 18:04:45 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def zeus_balance
|
|
|
|
User.zeus.balance
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|