]> source.dussan.org Git - redmine.git/commitdiff
Wrong done_ratio calculation for parent with subtask having estimated_hours=0 ().
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 11 Sep 2013 22:00:18 +0000 (22:00 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 11 Sep 2013 22:00:18 +0000 (22:00 +0000)
Patch by Daniel Felix.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12131 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb

index d04f5bd04156a24395006cbefe10047639a44c29..e6851e4fb568c0be0a1a05f30a53d7ad54233a3f 100644 (file)
@@ -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