From 68f8d009304e91bdc9a50c4033c2eeacaa0da2ff Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 Aug 2009 12:32:25 +0200 Subject: [PATCH] Fixed bug in stats on a fresh installation. --- app/views/home/_stats.erb | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/views/home/_stats.erb b/app/views/home/_stats.erb index 426c5709..c7f23c58 100644 --- a/app/views/home/_stats.erb +++ b/app/views/home/_stats.erb @@ -4,21 +4,23 @@ max_width = 600 global_avg = Ordergroup.avg_jobs_per_euro group_avg = @ordergroup.avg_jobs_per_euro.to_f -length_of_global_bar = max_width / 2.0 -length_of_group_bar = (group_avg / global_avg) * length_of_global_bar +unless global_avg == 0 or global_avg.nan? + length_of_global_bar = max_width / 2.0 + length_of_group_bar = (group_avg / global_avg) * length_of_global_bar -length_of_group_bar = max_width if length_of_group_bar > max_width + length_of_group_bar = max_width if length_of_group_bar > max_width -color = group_avg >= global_avg ? "#78b74e" : "red" + color = group_avg >= global_avg ? "#78b74e" : "red" %> -Engagement Deiner Bestellgruppe -
- <%= ((group_avg / global_avg) * 100).to_i -%><%= " Äpfel" if length_of_group_bar > 50 -%> -
-Durchschnittsengagement -
- 100 Birnen -
- - Abgebildet ist das Verhältnis von erledigten Aufgaben zu dem Bestellvolumen Deiner Bestellgruppe im Vergleich zum Durchschnitt in der Foodcoop. - \ No newline at end of file + Engagement Deiner Bestellgruppe +
+ <%= ((group_avg / global_avg) * 100).to_i -%><%= " Äpfel" if length_of_group_bar > 50 -%> +
+ Durchschnittsengagement +
+ 100 Birnen +
+ + Abgebildet ist das Verhältnis von erledigten Aufgaben zu dem Bestellvolumen Deiner Bestellgruppe im Vergleich zum Durchschnitt in der Foodcoop. + +<%- end -%>