From 9191e12ce9aeb9fbc5d0a5c425c0c989de214d37 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Mon, 14 Sep 2015 17:30:52 +0200 Subject: [PATCH] fix amount distribution, still ugly though --- app/controllers/concerns/statistics.rb | 4 ++-- app/views/pages/landing.html.haml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/statistics.rb b/app/controllers/concerns/statistics.rb index 6d91c67..e2f756f 100644 --- a/app/controllers/concerns/statistics.rb +++ b/app/controllers/concerns/statistics.rb @@ -25,8 +25,8 @@ class Statistics < Rails::Application end def amount_distribution - Transaction.group("round(amount / 1000.0, 2)").count.inject(Hash.new) do |hash, (group, count)| - hash.merge({10 * group.to_i => count}) + Transaction.group("round(amount / 1000)").count.inject(Hash.new) do |hash, (group, count)| + hash.merge({10 * group.to_f => count}) end end diff --git a/app/views/pages/landing.html.haml b/app/views/pages/landing.html.haml index eef0fbc..80f85a5 100644 --- a/app/views/pages/landing.html.haml +++ b/app/views/pages/landing.html.haml @@ -30,4 +30,5 @@ = pie_chart @statistics.by_issuer .pure-u-1-2 %h3 Distribution of Transaction Amounts + = @statistics.amount_distribution = column_chart @statistics.amount_distribution