Commit 9932d001 authored by jplang's avatar jplang

Always set spent_hours instance variables to a Float in Issue instances (#25526).

Patch by Holger Just.

git-svn-id: https://svn.redmine.org/redmine/trunk@16491 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 75b332a0
...@@ -1052,7 +1052,7 @@ class Issue < ActiveRecord::Base ...@@ -1052,7 +1052,7 @@ class Issue < ActiveRecord::Base
# Returns the number of hours spent on this issue # Returns the number of hours spent on this issue
def spent_hours def spent_hours
@spent_hours ||= time_entries.sum(:hours) || 0 @spent_hours ||= time_entries.sum(:hours) || 0.0
end end
# Returns the total number of hours spent on this issue and its descendants # Returns the total number of hours spent on this issue and its descendants
...@@ -1107,7 +1107,7 @@ class Issue < ActiveRecord::Base ...@@ -1107,7 +1107,7 @@ class Issue < ActiveRecord::Base
if issues.any? if issues.any?
hours_by_issue_id = TimeEntry.visible(user).where(:issue_id => issues.map(&:id)).group(:issue_id).sum(:hours) hours_by_issue_id = TimeEntry.visible(user).where(:issue_id => issues.map(&:id)).group(:issue_id).sum(:hours)
issues.each do |issue| issues.each do |issue|
issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0) issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0.0)
end end
end end
end end
...@@ -1120,7 +1120,7 @@ class Issue < ActiveRecord::Base ...@@ -1120,7 +1120,7 @@ class Issue < ActiveRecord::Base
" AND parent.lft <= #{Issue.table_name}.lft AND parent.rgt >= #{Issue.table_name}.rgt"). " AND parent.lft <= #{Issue.table_name}.lft AND parent.rgt >= #{Issue.table_name}.rgt").
where("parent.id IN (?)", issues.map(&:id)).group("parent.id").sum(:hours) where("parent.id IN (?)", issues.map(&:id)).group("parent.id").sum(:hours)
issues.each do |issue| issues.each do |issue|
issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0) issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0.0)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment