Fixed bug in stats on a fresh installation.

This commit is contained in:
root 2009-08-04 12:32:25 +02:00
parent d9d800b41f
commit 68f8d00930

View file

@ -4,21 +4,23 @@ max_width = 600
global_avg = Ordergroup.avg_jobs_per_euro global_avg = Ordergroup.avg_jobs_per_euro
group_avg = @ordergroup.avg_jobs_per_euro.to_f group_avg = @ordergroup.avg_jobs_per_euro.to_f
length_of_global_bar = max_width / 2.0 unless global_avg == 0 or global_avg.nan?
length_of_group_bar = (group_avg / global_avg) * length_of_global_bar 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 Engagement Deiner Bestellgruppe
<div class="stats-bar" style="width:<%= length_of_group_bar -%>px; background-color:<%= color -%>"> <div class="stats-bar" style="width:<%= length_of_group_bar -%>px; background-color:<%= color -%>">
<%= ((group_avg / global_avg) * 100).to_i -%><%= " Äpfel" if length_of_group_bar > 50 -%> <%= ((group_avg / global_avg) * 100).to_i -%><%= " Äpfel" if length_of_group_bar > 50 -%>
</div> </div>
Durchschnittsengagement Durchschnittsengagement
<div class="stats-bar" style="width:<%= length_of_global_bar -%>px"> <div class="stats-bar" style="width:<%= length_of_global_bar -%>px">
100 Birnen 100 Birnen
</div> </div>
<span class="description"> <span class="description">
Abgebildet ist das Verhältnis von erledigten Aufgaben zu dem Bestellvolumen Deiner Bestellgruppe im Vergleich zum Durchschnitt in der Foodcoop. Abgebildet ist das Verhältnis von erledigten Aufgaben zu dem Bestellvolumen Deiner Bestellgruppe im Vergleich zum Durchschnitt in der Foodcoop.
</span> </span>
<%- end -%>