0002-fix-attempt-for-23511.patch

Jens Krämer, 2016-08-23 04:33

Download (1.76 KB)

View differences:

app/models/issue.rb
1556 1556
        unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
1557 1557
          child_count = p.children.count
1558 1558
          if child_count > 0
1559
            average = p.children.where("estimated_hours > 0").average(:estimated_hours).to_f
1559
            average = (p.total_estimated_hours || 0) / child_count
1560 1560
            if average == 0
1561 1561
              average = 1
1562 1562
            end
1563
            done = p.children.joins(:status).
1564
              sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{average}) " +
1565
                  "* (CASE WHEN is_closed = #{self.class.connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)").to_f
1563
            done = p.children.inject(0) do |sum, c|
1564
              done_ratio = c.closed? ? 100 : (c.done_ratio || 0)
1565
              total = c.total_estimated_hours
1566
              if total.nil? || total == 0
1567
                sum + average * done_ratio
1568
              else
1569
                sum + (total * done_ratio)
1570
              end
1571
            end
1566 1572
            progress = done / (average * child_count)
1567 1573
            p.done_ratio = progress.round
1568 1574
          end
1569
-