From ce5c1e3fbe8d68b4d2584c65cc846e0930d31913 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Sat, 13 Apr 2019 21:26:51 +0200 Subject: [PATCH] Host the charting library ourselves instead of from Google This fixes the debt chart not working in Firefox (has a built-in tracking blocker). Also made chart nicer to display by adding percentages --- app/assets/javascripts/application.js | 2 ++ app/controllers/concerns/statistics.rb | 3 +-- app/views/pages/sign_in_page.html.haml | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1de917d..8362bf4 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -22,6 +22,8 @@ //= require react //= require react_ujs //= require components +//= require Chart.bundle +//= require chartkick //= require_tree . ready = function() { diff --git a/app/controllers/concerns/statistics.rb b/app/controllers/concerns/statistics.rb index ce17079..11b9ded 100644 --- a/app/controllers/concerns/statistics.rb +++ b/app/controllers/concerns/statistics.rb @@ -12,7 +12,7 @@ class Statistics < Rails::Application def shamehash none_shaming = total_debt + shameful_users.sum(:balance) shameful_users.inject({'Reputable users' => none_shaming.to_f / total_debt}) do |h, u| - h.merge({u.name => - u.balance.to_f / total_debt}) + h.merge({u.name => - u.balance.to_f / total_debt * 100.0}) end end @@ -31,4 +31,3 @@ class Statistics < Rails::Application .take([shameful_users.count, 4].max) end end - diff --git a/app/views/pages/sign_in_page.html.haml b/app/views/pages/sign_in_page.html.haml index d749f99..a2b9a97 100644 --- a/app/views/pages/sign_in_page.html.haml +++ b/app/views/pages/sign_in_page.html.haml @@ -1,5 +1,4 @@ %h1.columns-title Tab -= javascript_include_tag "//www.google.com/jsapi", "chartkick" .pure-g.landing_columns .pure-u-1.pure-u-md-1-2 %h2 Authentication @@ -7,4 +6,4 @@ %p= link_to "Log in met Zeus WPI", user_zeuswpi_omniauth_authorize_path, class: "pure-button pure-button-primary login-button" .pure-u-1.pure-u-md-1-2 %h2 Pie of Shame - = pie_chart @statistics.shamehash + = pie_chart @statistics.shamehash, suffix: '%'