[#4183] Implemented Contract#estimated_hour_spent and Deliverable#hours_spent_total.

This commit is contained in:
Eric Davis committed 2010-07-13 11:34:22 -07:00
1 parent af99dc4042
commit b24ab65792
3 files changed
+31 -2

No files matched your search

+6 -2
View File
@@ -41,8 +41,7 @@ class Contract < ActiveRecord::Base
[:labor_spent,
:overhead_spent,
:total_spent,
:profit_spent,
:estimated_hour_spent
:profit_spent
].each do |mthd|
define_method(mthd) { "TODO" }
end
@@ -62,6 +61,11 @@ class Contract < ActiveRecord::Base
deliverables.inject(0) {|total, deliverable| total += deliverable.estimated_hour_budget_total }
end
# OPTIMIZE: N+1
def estimated_hour_spent
deliverables.inject(0) {|total, deliverable| total += deliverable.hours_spent_total }
end
# OPTIMIZE: N+1
def total_budget
deliverables.inject(0) {|total, deliverable| total += deliverable.total }
+5
View File
@@ -48,6 +48,11 @@ class Deliverable < ActiveRecord::Base
(overhead_budgets.sum(:hours) || 0.0)
end
# OPTIMIZE: N+1
def hours_spent_total
issues.inject(0) {|total, issue| total += issue.spent_hours }
end
if Rails.env.test?
generator_for :title, :method => :next_title