add distributions of debt sources and transaction amounts
This commit is contained in:
parent
c9010f59ee
commit
9302c3533b
2 changed files with 22 additions and 3 deletions
|
@ -17,6 +17,18 @@ class Statistics < Rails::Application
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def by_issuer
|
||||||
|
Transaction.group(:issuer_id).count.inject(Hash.new) do |hash, (id, count)|
|
||||||
|
hash.merge({User.find(id).name => count})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def amount_distribution
|
||||||
|
Transaction.group("round(amount / 10)").count.inject(Hash.new) do |hash, (group, count)|
|
||||||
|
hash.merge({10 * group.to_i => count})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def zeus_balance
|
def zeus_balance
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
Log een keer in!
|
Log een keer in!
|
||||||
%p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi)
|
%p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi)
|
||||||
%h2 Cute Little Statistics
|
%h2 Cute Little Statistics
|
||||||
%p None here yet.
|
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
|
||||||
%h2 Wall of Shame
|
|
||||||
.pure-g
|
.pure-g
|
||||||
.pure-u-1-2
|
.pure-u-1-2
|
||||||
|
%h3 Table of Shame
|
||||||
%table.pure-table
|
%table.pure-table
|
||||||
%thead
|
%thead
|
||||||
%th Shame on
|
%th Shame on
|
||||||
|
@ -22,5 +22,12 @@
|
||||||
// a shameful debt if the total debt is zero.
|
// a shameful debt if the total debt is zero.
|
||||||
%td.shame-percentage= "#{100 * user.balance / @statistics.total_debt}%"
|
%td.shame-percentage= "#{100 * user.balance / @statistics.total_debt}%"
|
||||||
.pure-u-1-2
|
.pure-u-1-2
|
||||||
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
|
%h3 Pie of Shame
|
||||||
= pie_chart @statistics.shamehash
|
= pie_chart @statistics.shamehash
|
||||||
|
.pure-g
|
||||||
|
.pure-u-1-2
|
||||||
|
%h3 Distribution of Debt Sources
|
||||||
|
= pie_chart @statistics.by_issuer
|
||||||
|
.pure-u-1-2
|
||||||
|
%h3 Distribution of Transaction Amounts
|
||||||
|
= column_chart @statistics.amount_distribution
|
||||||
|
|
Loading…
Reference in a new issue