https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292016-01-06T03:55:18ZRedmineRedmine - Defect #21449: Automatic done ratio calculation in issue tree is wrong when parent has its own estimated timehttps://www.redmine.org/issues/21449?journal_id=682822016-01-06T03:55:18ZToshi MARUYAMA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-5 priority-high2 closed" href="/issues/16092">Defect #16092</a>: Parent/subtask: calculation of estimated hours</i> added</li></ul> Redmine - Defect #21449: Automatic done ratio calculation in issue tree is wrong when parent has its own estimated timehttps://www.redmine.org/issues/21449?journal_id=979322020-05-25T20:47:01ZSebastian Paluch
<ul></ul><p>This issue still exists in Redmine 4.1.0 and this is big issue. Don't know why none complains about this.</p> Redmine - Defect #21449: Automatic done ratio calculation in issue tree is wrong when parent has its own estimated timehttps://www.redmine.org/issues/21449?journal_id=989642020-08-27T18:13:06ZSebastian Paluch
<ul></ul><p>It seems that the equation in <code>recalculate_attributes_for</code> has to be changed to include the estimate time of the issue to:</p>
<pre><code>
total_estimated = p.estimated_hours.to_f || 0.0
children = p.children.to_a
if children.any?
if p.closed?
p.done_ratio = 100
else
done = children.map {|c|
estimated = c.total_estimated_hours.to_f
total_estimated += estimated
ratio = c.closed? ? 100 : (c.done_ratio || 0)
estimated * ratio / 100.0
}.sum
progress = ((total_estimated - done) / total_estimated) * 100
p.done_ratio = 100 - progress.floor
end
# ancestors will be recursively updated
p.save(:validate => false)
end
</code></pre>
<p>The problem with this is that this will correctly update "% Done" of all parents (A) recursively but it will not update "% Done" of currently edited issue (B) if the issue is also a parent (for C).</p>
<p>I have tried moving this recalculation to before_save callback, so that it can modify the issue (B) and this works correctly, "% Done" of current issue (B) and all parents (A) is updated.</p>
<p>This creates though small inconsistency in journals. Normally updates to derived "% Done" are not save into journal. But in the case, when issues (B) is edited and it has derived "% Done" (because it is parent for C), the new "% Done" value gets saved into journal. This is not OK as the "% Done" may be changed at any time if any subtask (C) is modified - since this operation is not be saved in journal, now the issue (B) shows different value of "% Done" then visible in last journal entry. So, confusing. And I don't know how to solve this problem.</p>