Project

General

Profile

Defect #14798 ยป patch_done_ratio_on_zero_values.diff

Daniel Felix, 2013-08-29 10:13

View differences:

app/models/issue.rb
1364 1364
          if average == 0
1365 1365
            average = 1
1366 1366
          end
1367
          done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f
1367
          done = p.leaves.sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{average}) " +
1368
			"* (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f
1368 1369
          progress = done / (average * leaves_count)
1369 1370
          p.done_ratio = progress.round
1370 1371
        end
    (1-1/1)