Minor refactoring in stats partial.

This commit is contained in:
benni 2012-06-24 21:43:36 +02:00
parent 4b6499d529
commit f1b71a5588
2 changed files with 7 additions and 1 deletions

View file

@ -62,6 +62,12 @@ class Ordergroup < Group
stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0 stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0
end end
# This is the ordergroup job per euro performance
# in comparison to the hole foodcoop average
def apples
((avg_jobs_per_euro / Ordergroup.avg_jobs_per_euro) * 100).to_i rescue 0
end
# Global average # Global average
def self.avg_jobs_per_euro def self.avg_jobs_per_euro
stats = Ordergroup.all.collect(&:stats) stats = Ordergroup.all.collect(&:stats)

View file

@ -14,7 +14,7 @@ unless global_avg == 0 or global_avg.nan?
%> %>
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 -%> <%= @ordergroup.apples -%><%= " Ä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">