Consider task duration in ordergroup stats.

* Also added duration to task template in workgroup task_duration.
This commit is contained in:
benni 2011-05-07 21:54:00 +02:00
parent be85296ddb
commit c2496aa4fd
19 changed files with 80 additions and 32 deletions

View file

@ -49,7 +49,7 @@ end
# type :string(255) default(""), not null
# name :string(255) default(""), not null
# description :string(255)
# account_balance :decimal(8, 2) default(0.0), not null
# account_balance :decimal(, ) default(0.0), not null
# account_updated :datetime
# created_on :datetime not null
# role_admin :boolean default(FALSE), not null
@ -67,5 +67,6 @@ end
# contact_phone :string(255)
# contact_address :string(255)
# stats :text
# task_duration :integer default(1)
#

View file

@ -53,7 +53,7 @@ class Ordergroup < Group
def update_stats!
time = 6.month.ago
jobs = users.collect { |u| u.tasks.done.all(:conditions => ["updated_on > ?", time]).size }.sum
jobs = users.collect { |u| u.tasks.done.sum('duration', :conditions => ["updated_on > ?", time]) }.sum
orders_sum = group_orders.select { |go| !go.order.ends.nil? && go.order.ends > time }.collect(&:price).sum
update_attribute(:stats, {:jobs_size => jobs, :orders_sum => orders_sum})
end
@ -91,7 +91,7 @@ end
# type :string(255) default(""), not null
# name :string(255) default(""), not null
# description :string(255)
# account_balance :decimal(8, 2) default(0.0), not null
# account_balance :decimal(, ) default(0.0), not null
# account_updated :datetime
# created_on :datetime not null
# role_admin :boolean default(FALSE), not null
@ -109,5 +109,6 @@ end
# contact_phone :string(255)
# contact_address :string(255)
# stats :text
# task_duration :integer default(1)
#

View file

@ -11,6 +11,7 @@ class Task < ActiveRecord::Base
attr_protected :users
validates_length_of :name, :minimum => 3
validates_numericality_of :duration, :in => 1..3
after_save :update_ordergroup_stats
@ -67,7 +68,7 @@ class Task < ActiveRecord::Base
def update_ordergroup_stats
if done
users.each { |u| u.ordergroup.update_stats! }
users.each { |u| u.ordergroup.update_stats! if u.ordergroup }
end
end
end
@ -87,6 +88,6 @@ end
# updated_on :datetime not null
# required_users :integer default(1)
# weekly :boolean
# duration :integer
# duration :integer default(1)
#

View file

@ -34,11 +34,12 @@ class Workgroup < Group
def task_attributes(date)
{
:name => task_name,
:description => task_description,
:due_date => date,
:required_users => task_required_users,
:weekly => true
:name => task_name,
:description => task_description,
:due_date => date,
:required_users => task_required_users,
:duration => task_duration,
:weekly => true
}
end
@ -52,7 +53,7 @@ end
# type :string(255) default(""), not null
# name :string(255) default(""), not null
# description :string(255)
# account_balance :decimal(8, 2) default(0.0), not null
# account_balance :decimal(, ) default(0.0), not null
# account_updated :datetime
# created_on :datetime not null
# role_admin :boolean default(FALSE), not null
@ -70,5 +71,6 @@ end
# contact_phone :string(255)
# contact_address :string(255)
# stats :text
# task_duration :integer default(1)
#

View file

@ -31,6 +31,10 @@
%td
= @form.label :task_required_users, "Benötigte Verantwortliche:"
%td= @form.text_field :task_required_users, :size => 3
%tr
%td
= @form.label :task_duration, "Vor. Dauer in Stunden"
%td= @form.select :task_duration, options_for_select(1..3, @group.task_duration)
%tr
%td
= @form.label :task_description, "Beschreibung:"
@ -45,11 +49,13 @@
$('workgroup_weekday').disabled = false;
$('workgroup_task_name').disabled = false;
$('workgroup_task_required_users').disabled = false;
$('workgroup_task_duration').disabled = false;
$('workgroup_task_description').disabled = false;
} else {
$('workgroup_weekday').disabled = true;
$('workgroup_task_name').disabled = true;
$('workgroup_task_required_users').disabled = true;
$('workgroup_task_duration').disabled = true;
$('workgroup_task_description').disabled = true;
}
}

View file

@ -8,6 +8,11 @@
%b Beschreibung
%br/
= form.text_area :description, :cols => 50, :rows => 10
%p
%b Dauer
%small Wie lange dauert die Aufgabe, 1-3 Stunden
%br/
= form.select :duration, options_for_select(1..3, @task.duration)
%p
%b Verantwortliche
%small Aufgaben können mehrere Verantwortliche haben

View file

@ -9,7 +9,7 @@
- done = task.done ? " done" : ""
%tr{:class => cycle('even','odd', :name => "tasks") + done }
%td= format_date(task.due_date) unless task.due_date.nil?
%td= link_to task.name, task_path(task)
%td= link_to "#{task.name} (#{task.duration}h)", task_path(task)
%td
- unless task.users.empty?
- owner = Array.new

View file

@ -12,7 +12,7 @@
- for task in @tasks
%tr{:class => cycle('even','odd')}
%td= task.due_date unless task.due_date.nil?
%td= link_to task.name, :controller => "tasks", :action => "show", :id => task
%td= link_to "#{task.name} (#{task.duration}h)", :controller => "tasks", :action => "show", :id => task
%td
- unless task.users.empty?
= task.users.map(&:nick).join(", ")

View file

@ -13,6 +13,9 @@
%tr
%td Fälligkeitsdatum
%td= format_date(@task.due_date)
%tr
%td Dauer in Stunden
%td= @task.duration
%tr
%td Verantwortliche Menschen
%td= render :partial => "assignments"