From: Jean-Philippe Lang Date: Wed, 11 Sep 2013 22:00:18 +0000 (+0000) Subject: Wrong done_ratio calculation for parent with subtask having estimated_hours=0 (). X-Git-Tag: 2.4.0~118 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cb747a34effe57a268d768e8a4174a9425ed2f27;p=redmine.git Wrong done_ratio calculation for parent with subtask having estimated_hours=0 (). Patch by Daniel Felix. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12131 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/issue.rb b/app/models/issue.rb index d04f5bd04..e6851e4fb 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1364,7 +1364,8 @@ class Issue < ActiveRecord::Base if average == 0 average = 1 end - 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 + done = p.leaves.sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{average}) " + + "* (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f progress = done / (average * leaves_count) p.done_ratio = progress.round end