diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-11-14 09:58:52 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-11-14 09:58:52 +0000 |
commit | 1a860d5320aa192baa886810653f7019fe077602 (patch) | |
tree | 8359633c61ebd68e40f1c6b8bc7ba0bc5732d979 /app/models | |
parent | 5735db1a9154ba73fbe28d726450dc6895506c0e (diff) | |
download | redmine-1a860d5320aa192baa886810653f7019fe077602.tar.gz redmine-1a860d5320aa192baa886810653f7019fe077602.zip |
Calculate done_ratio based on children instead of leaves (#20995).
Patch by Jens Krämer.
git-svn-id: http://svn.redmine.org/redmine/trunk@14875 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 5da5f4d50..707c4581c 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1529,16 +1529,16 @@ class Issue < ActiveRecord::Base if p.done_ratio_derived? # done ratio = weighted average ratio of leaves unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio - leaves_count = p.leaves.count - if leaves_count > 0 - average = p.leaves.where("estimated_hours > 0").average(:estimated_hours).to_f + child_count = p.children.count + if child_count > 0 + average = p.children.where("estimated_hours > 0").average(:estimated_hours).to_f if average == 0 average = 1 end - done = p.leaves.joins(:status). + done = p.children.joins(:status). sum("COALESCE(CASE WHEN estimated_hours > 0 THEN estimated_hours ELSE NULL END, #{average}) " + "* (CASE WHEN is_closed = #{self.class.connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)").to_f - progress = done / (average * leaves_count) + progress = done / (average * child_count) p.done_ratio = progress.round end end |