From 6b38dfca9181561267e61f37ef5ad316df0d9e92 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 9 Sep 2010 15:43:38 -0700 Subject: [PATCH] Refactor: use utility method. --- app/models/retainer_deliverable.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/models/retainer_deliverable.rb b/app/models/retainer_deliverable.rb index 093ec40..54894b8 100644 --- a/app/models/retainer_deliverable.rb +++ b/app/models/retainer_deliverable.rb @@ -125,15 +125,8 @@ class RetainerDeliverable < HourlyDeliverable return 0 unless self.issues.count > 0 issue_ids = self.issues.collect(&:id) - if issue_ids.present? - time_logs = TimeEntry.all(:conditions => ["#{Issue.table_name}.id IN (:issue_ids) AND tyear = (:year) AND tmonth = (:month)", - {:issue_ids => issue_ids, - :year => date.year, - :month => date.month} - ], - :include => :issue) - end - time_logs ||= [] + time_logs = time_entries_for_date_and_issue_ids(date, issue_ids) + hours = time_logs.inject(0) {|total, time_entry| total += time_entry.hours if time_entry.billable? total