Patch #25526 ยป 0001-Always-set-spent_hours-instance-variables-to-a-Float.patch
| app/models/issue.rb | ||
|---|---|---|
|
# Returns the number of hours spent on this issue
|
||
|
def spent_hours
|
||
|
@spent_hours ||= time_entries.sum(:hours) || 0
|
||
|
@spent_hours ||= time_entries.sum(:hours) || 0.0
|
||
|
end
|
||
|
# Returns the total number of hours spent on this issue and its descendants
|
||
| ... | ... | |
|
if issues.any?
|
||
|
hours_by_issue_id = TimeEntry.visible(user).where(:issue_id => issues.map(&:id)).group(:issue_id).sum(:hours)
|
||
|
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
|
||
| ... | ... | |
|
" 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)
|
||
|
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
|
||