Bug #2213
openxmera Omnia - Collection #2189: RM related issues
Parent task does not inherit %-done form subtasks when it should calculate progress from issue status
80%
Description
Assuming this settings
a user could expect to get the "%-done" value of the parent to be calculated from its subtasks when using default "%-done" values for issue status.
There is already a Redmine issue describing the situation: https://www.redmine.org/issues/6609.
- Resolve the issue
- Refactor if necessary
- Write tests
- Prepare a patch
- Integrate the patch in your local development environment
- Integrate the patch in our build process
- Create a separate issue to share the patch with redmine.org and relate it to this issue
Files
Updated by liaham 9 months ago
The problem is in app/models/issue.rb
:
def recalculate_attributes_for(issue_id)
if issue_id && p = Issue.find_by_id(issue_id)
if p.priority_derived?
# priority = highest priority of open children
# priority is left unchanged if all children are closed and there's no default priority defined
if priority_position =
p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position")
p.priority = IssuePriority.find_by_position(priority_position)
elsif default_priority = IssuePriority.default
p.priority = default_priority
end
end
if p.dates_derived?
# start/due dates = lowest/highest dates of children
p.start_date = p.children.minimum(:start_date)
p.due_date = p.children.maximum(:due_date)
if p.start_date && p.due_date && p.due_date < p.start_date
p.start_date, p.due_date = p.due_date, p.start_date
end
end
if p.done_ratio_derived?
# done ratio = average ratio of children weighted with their total estimated hours
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio # <--- !!!!
children = p.children.to_a
if children.any?
child_with_total_estimated_hours = children.select {|c| c.total_estimated_hours.to_f > 0.0}
if child_with_total_estimated_hours.any?
average = Rational(
child_with_total_estimated_hours.sum(&:total_estimated_hours).to_s,
child_with_total_estimated_hours.count
)
else
average = Rational(1)
end
done = children.sum do |c|
estimated = Rational(c.total_estimated_hours.to_f.to_s)
estimated = average unless estimated > 0.0
ratio = c.closed? ? 100 : (c.done_ratio || 0)
estimated * ratio
end
progress = Rational(done, average * children.count)
p.done_ratio = progress.floor
end
end
end
# ancestors will be recursively updated
p.save(:validate => false)
end
end
Updated by liaham 9 months ago
- File clipboard-202407251701-ai66c.png clipboard-202407251701-ai66c.png added
- Description updated (diff)
Updated by liaham 8 months ago
There are some edge cases to consider when assigning a status to the parent based on the average of the children done ratios when trying to find the closest status for this average:
- Average of the children done ratios = 0 <==> done_ratio of all children must be 0 or nil. Nil is treated equal to 0. (See
(c.done_ratio || 0)
below.) - There is at least one status.default_done_ratio of nil.
- Several status.default_done_ratios are equal.
Updated by liaham 8 months ago
Open questions
- What if the parent issue does not have the same tracker then the child issues?
Child issues are not relevant since we use only the children average of their done ratio.
- What if an issue has statuses having the same %-done value assigned?
It is not possible to decide which status is right when at least two status have the same %-done value!
Updated by liaham 8 months ago
- Subject changed from Parent task does not inherit %-done form subtasks when it should calculates progress from issue status to Parent task does not inherit %-done form subtasks when it should calculate progress from issue status
- Status changed from Closed to Feedback
- % Done changed from 100 to 80
There is a new point of view:
This issue is not a bug fix but a feature.
Changing the status of a parent is not what the settings above are about. Choosing Calculate the issue done ratio with the issue status
and Calculate %-done from subtasks
for parent issues does not imply to change the parent status. There is no option which states to do so.
In order to have room for calculating the parent's done ratio derived from its children the parent would need to have a status without %-done value assigned. If the status would have a %-done value predefined it would not be overridden by the children's average. That is understandable, but only at second glance.
Changing the status would be a new feature which can apply only with Calculate the issue done ratio with the issue status
. Otherwise it would not be clear to what status to change based on the average done ratio from the parents children.