Project

General

Profile

Patch #25526 ยป 0001-Always-set-spent_hours-instance-variables-to-a-Float.patch

Holger Just, 2017-04-05 15:28

View differences:

app/models/issue.rb
1052 1052

  
1053 1053
  # Returns the number of hours spent on this issue
1054 1054
  def spent_hours
1055
    @spent_hours ||= time_entries.sum(:hours) || 0
1055
    @spent_hours ||= time_entries.sum(:hours) || 0.0
1056 1056
  end
1057 1057

  
1058 1058
  # Returns the total number of hours spent on this issue and its descendants
......
1107 1107
    if issues.any?
1108 1108
      hours_by_issue_id = TimeEntry.visible(user).where(:issue_id => issues.map(&:id)).group(:issue_id).sum(:hours)
1109 1109
      issues.each do |issue|
1110
        issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
1110
        issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0.0)
1111 1111
      end
1112 1112
    end
1113 1113
  end
......
1120 1120
          " AND parent.lft <= #{Issue.table_name}.lft AND parent.rgt >= #{Issue.table_name}.rgt").
1121 1121
        where("parent.id IN (?)", issues.map(&:id)).group("parent.id").sum(:hours)
1122 1122
      issues.each do |issue|
1123
        issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0)
1123
        issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0.0)
1124 1124
      end
1125 1125
    end
1126 1126
  end
    (1-1/1)