add shamepie -- the big slices are really gross!
This commit is contained in:
parent
eb2c85aa9f
commit
c9010f59ee
4 changed files with 27 additions and 11 deletions
2
Gemfile
2
Gemfile
|
@ -35,6 +35,8 @@ gem 'jquery-datatables-rails'
|
||||||
# Use Select2 for selecting users
|
# Use Select2 for selecting users
|
||||||
gem 'select2-rails'
|
gem 'select2-rails'
|
||||||
|
|
||||||
|
# Chartkick for fancy graphs
|
||||||
|
gem 'chartkick'
|
||||||
|
|
||||||
# Use jquery as the JavaScript library
|
# Use jquery as the JavaScript library
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
|
|
|
@ -70,6 +70,7 @@ GEM
|
||||||
capistrano-rbenv (2.0.3)
|
capistrano-rbenv (2.0.3)
|
||||||
capistrano (~> 3.1)
|
capistrano (~> 3.1)
|
||||||
sshkit (~> 1.3)
|
sshkit (~> 1.3)
|
||||||
|
chartkick (1.3.2)
|
||||||
coffee-rails (4.1.0)
|
coffee-rails (4.1.0)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
|
@ -296,6 +297,7 @@ DEPENDENCIES
|
||||||
capistrano-passenger
|
capistrano-passenger
|
||||||
capistrano-rails (~> 1.1)
|
capistrano-rails (~> 1.1)
|
||||||
capistrano-rbenv
|
capistrano-rbenv
|
||||||
|
chartkick
|
||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
coveralls
|
coveralls
|
||||||
devise
|
devise
|
||||||
|
|
|
@ -10,6 +10,13 @@ class Statistics < Rails::Application
|
||||||
User.where.not(id: User.zeus).where('balance > 0').sum(:balance)
|
User.where.not(id: User.zeus).where('balance > 0').sum(:balance)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def zeus_balance
|
def zeus_balance
|
||||||
|
|
|
@ -8,14 +8,19 @@
|
||||||
%h2 Cute Little Statistics
|
%h2 Cute Little Statistics
|
||||||
%p None here yet.
|
%p None here yet.
|
||||||
%h2 Wall of Shame
|
%h2 Wall of Shame
|
||||||
%table.pure-table
|
.pure-g
|
||||||
%thead
|
.pure-u-1-2
|
||||||
%th Shame on
|
%table.pure-table
|
||||||
%th Contribution to Zeus' lack of money
|
%thead
|
||||||
%tbody
|
%th Shame on
|
||||||
- @statistics.shameful_users.each do |user|
|
%th Contribution to Zeus' lack of money
|
||||||
%tr
|
%tbody
|
||||||
%td.shameful-person= user.name
|
- @statistics.shameful_users.each do |user|
|
||||||
// Won't divide by zero because there won't be any users with
|
%tr
|
||||||
// a shameful debt if the total debt is zero.
|
%td.shameful-person= user.name
|
||||||
%td.shame-percentage= "#{100 * user.balance / @statistics.total_debt}%"
|
// Won't divide by zero because there won't be any users with
|
||||||
|
// a shameful debt if the total debt is zero.
|
||||||
|
%td.shame-percentage= "#{100 * user.balance / @statistics.total_debt}%"
|
||||||
|
.pure-u-1-2
|
||||||
|
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
|
||||||
|
= pie_chart @statistics.shamehash
|
||||||
|
|
Loading…
Reference in a new issue