add shamepie -- the big slices are really gross!

This commit is contained in:
Felix Van der Jeugt 2015-09-12 00:17:43 +02:00
parent eb2c85aa9f
commit c9010f59ee
4 changed files with 27 additions and 11 deletions

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -8,6 +8,8 @@
%h2 Cute Little Statistics %h2 Cute Little Statistics
%p None here yet. %p None here yet.
%h2 Wall of Shame %h2 Wall of Shame
.pure-g
.pure-u-1-2
%table.pure-table %table.pure-table
%thead %thead
%th Shame on %th Shame on
@ -19,3 +21,6 @@
// Won't divide by zero because there won't be any users with // Won't divide by zero because there won't be any users with
// 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
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
= pie_chart @statistics.shamehash