Implemented stats for ordergroups on startpage. Annotated models.

This commit is contained in:
Benjamin Meichsner 2009-08-01 13:41:22 +02:00
parent 709425855e
commit d848831fea
65 changed files with 407 additions and 338 deletions

24
app/views/home/_stats.erb Normal file
View file

@ -0,0 +1,24 @@
<%
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
length_of_group_bar = max_width if length_of_group_bar > max_width
color = group_avg >= global_avg ? "#78b74e" : "red"
%>
Engagement Deiner Bestellgruppe
<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 -%>
</div>
Durchschnittsengagement
<div class="stats-bar" style="width:<%= length_of_global_bar -%>px">
100 Birnen
</div>
<span class="description">
Abgebildet ist das Verhältnis von erledigten Aufgaben zu dem Bestellvolumen Deiner Bestellgruppe im Vergleich zum Durchschnitt in der Foodcoop.
</span>

View file

@ -31,6 +31,12 @@
// Current orders
= render :partial => 'shared/open_orders'
// Stats
.box_title
%h2 Engagement Deiner Bestellgruppe
.column_content
= render "stats"
- unless @messages.empty?
.box_title
%h2 Neuste Nachrichten
@ -49,9 +55,9 @@
|
Verfügbares Guthaben:
= number_to_currency(@ordergroup.get_available_funds())
%span{:style => "color:grey"}
(zuletzt aktualisiert vor
= distance_of_time_in_words(Time.now, @ordergroup.account_updated) + "(n))"
%span.description
(Letzte Aktualisierung ist
= distance_of_time_in_words(Time.now, @ordergroup.account_updated) + " her)"
%h3 Letzte Transaktionen
%table
%tr