]> source.dussan.org Git - redmine.git/commitdiff
Rails4: replace deprecated Relation#sum with finder options at Issue#total_spent_hours
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 10 Jan 2014 05:02:44 +0000 (05:02 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 10 Jan 2014 05:02:44 +0000 (05:02 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12588 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb

index abf4cec92104b18185fed122f61d4bd278840e16..6cfe97927cfe5045100e882ff204b8f0608b7d42 100644 (file)
@@ -839,8 +839,10 @@ class Issue < ActiveRecord::Base
   #   spent_hours => 0.0
   #   spent_hours => 50.2
   def total_spent_hours
-    @total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours",
-      :joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0
+    @total_spent_hours ||=
+      self_and_descendants.
+        joins("LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").
+        sum("#{TimeEntry.table_name}.hours").to_f || 0.0
   end
 
   def relations