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

@ -38,6 +38,7 @@ class Workgroup < Group
: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"

View file

@ -1,6 +1,6 @@
class AddDurationToTasks < ActiveRecord::Migration
def self.up
add_column :tasks, :duration, :integer
add_column :tasks, :duration, :integer, :default => 1
end
def self.down

View file

@ -0,0 +1,9 @@
class AddTaskDurationToWorkgroups < ActiveRecord::Migration
def self.up
add_column :groups, :task_duration, :integer, :default => 1
end
def self.down
remove_column :groups, :task_duration
end
end

View file

@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110507184920) do
ActiveRecord::Schema.define(:version => 20110507192928) do
create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false
@ -132,7 +132,7 @@ ActiveRecord::Schema.define(:version => 20110507184920) do
t.string "type", :default => "", :null => false
t.string "name", :default => "", :null => false
t.string "description"
t.decimal "account_balance", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal "account_balance", :default => 0.0, :null => false
t.datetime "account_updated"
t.datetime "created_on", :null => false
t.boolean "role_admin", :default => false, :null => false
@ -150,6 +150,7 @@ ActiveRecord::Schema.define(:version => 20110507184920) do
t.string "contact_phone"
t.string "contact_address"
t.text "stats"
t.integer "task_duration", :default => 1
end
add_index "groups", ["name"], :name => "index_groups_on_name", :unique => true
@ -311,7 +312,7 @@ ActiveRecord::Schema.define(:version => 20110507184920) do
t.datetime "updated_on", :null => false
t.integer "required_users", :default => 1
t.boolean "weekly"
t.integer "duration"
t.integer "duration", :default => 1
end
add_index "tasks", ["due_date"], :name => "index_tasks_on_due_date"

View file

@ -76,6 +76,10 @@ applejuice:
tax: 7.0
# == Schema Information
#
# Table name: articles

View file

@ -17,6 +17,8 @@ bananas:
contact_phone: 030 123132456
contact_address: Waldermarstrasse 43, 10988 Berlin
# == Schema Information
#
# Table name: groups
@ -25,7 +27,7 @@ bananas:
# 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
@ -43,5 +45,6 @@ bananas:
# contact_phone :string(255)
# contact_address :string(255)
# stats :text
# task_duration :integer default(1)
#

View file

@ -41,6 +41,10 @@ terra:
# == Schema Information
#
# Table name: suppliers

View file

@ -1,5 +1,6 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
# == Schema Information
#
# Table name: tasks
@ -15,6 +16,6 @@
# updated_on :datetime not null
# required_users :integer default(1)
# weekly :boolean
# duration :integer
# duration :integer default(1)
#

View file

@ -9,6 +9,8 @@ class GroupTest < Test::Unit::TestCase
end
end
# == Schema Information
#
# Table name: groups
@ -17,7 +19,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
@ -35,5 +37,6 @@ end
# contact_phone :string(255)
# contact_address :string(255)
# stats :text
# task_duration :integer default(1)
#

View file

@ -9,6 +9,7 @@ class TaskTest < Test::Unit::TestCase
end
end
# == Schema Information
#
# Table name: tasks
@ -24,6 +25,6 @@ end
# updated_on :datetime not null
# required_users :integer default(1)
# weekly :boolean
# duration :integer
# duration :integer default(1)
#

View file

@ -7,6 +7,8 @@ class WorkgroupTest < ActiveSupport::TestCase
end
end
# == Schema Information
#
# Table name: groups
@ -15,7 +17,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
@ -33,5 +35,6 @@ end
# contact_phone :string(255)
# contact_address :string(255)
# stats :text
# task_duration :integer default(1)
#