Project

General

Profile

Actions

Bug #2213

open

xmera Omnia - Collection #2189: RM related issues

Parent task does not inherit %-done form subtasks when it should calculate progress from issue status

Added by liaham 9 months ago. Updated 7 months ago.

Status:
Feedback
Priority:
Normal
Assignee:
Target version:
Start date:
07/25/2024
Due date:
08/05/2024 (about 8 months late)
% Done:

80%

Estimated time:
Affected Version:
Compatible Redmine Version:
5.1.z

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


Related issues 2 (2 open0 closed)

Copied to Redmine - Bug #2267: Parent task does not inherit %-done form subtasks when it should calculates progress from issue statusNewliaham07/25/202407/25/2024

Actions
Copied to Redmine - Bug #2285: Parent task does not inherit %-done form subtasks when it should calculates progress from issue statusNewliaham

Actions
Actions #1

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

Actions #2

Updated by liaham 9 months ago

  • Parent task set to #2012
Actions #3

Updated by liaham 9 months ago

  • Parent task changed from #2012 to #2227
Actions #4

Updated by liaham 9 months ago

  • Subject changed from Parent task does not inherit %-done form subtasks when it should calculate progress from issue status to Parent task does not inherit %-done form subtasks when it should calculates progress from issue status
Actions #5

Updated by liaham 9 months ago

Created a branch: fix-calculating-done-ratio-of-parent-task-from-issue-status.

Actions #6

Updated by liaham 9 months ago

  • Due date set to 07/25/2024
  • Status changed from New to In Progress
  • Assignee set to liaham
  • Start date set to 07/25/2024
  • % Done changed from 0 to 20
Actions #7

Updated by liaham 9 months ago

Actions #8

Updated by liaham 9 months ago

  • Description updated (diff)
  • % Done changed from 20 to 30
Actions #9

Updated by liaham 9 months ago

  • Description updated (diff)
Actions #10

Updated by liaham 8 months ago

  • % Done changed from 30 to 40
Actions #11

Updated by liaham 8 months ago

  • Description updated (diff)
Actions #12

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:

  1. 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.)
  2. There is at least one status.default_done_ratio of nil.
  3. Several status.default_done_ratios are equal.
Actions #13

Updated by liaham 8 months ago

  • Description updated (diff)
  • % Done changed from 40 to 60
Actions #14

Updated by liaham 8 months ago

  • Description updated (diff)
  • % Done changed from 60 to 70
Actions #15

Updated by liaham 8 months ago

  • Description updated (diff)
Actions #16

Updated by liaham 8 months ago

  • Category set to 36
Actions #17

Updated by liaham 8 months ago

  • Copied to Bug #2267: Parent task does not inherit %-done form subtasks when it should calculates progress from issue status added
Actions #18

Updated by liaham 8 months ago

  • Target version set to 5.1.3
Actions #20

Updated by liaham 8 months ago

Open questions

  1. 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.

  1. 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!

Actions #21

Updated by liaham 8 months ago

  • Copied to Bug #2285: Parent task does not inherit %-done form subtasks when it should calculates progress from issue status added
Actions #22

Updated by liaham 8 months ago

  • Description updated (diff)
  • % Done changed from 70 to 100
Actions #23

Updated by liaham 8 months ago

  • Due date changed from 07/25/2024 to 08/05/2024
  • Status changed from In Progress to Closed
Actions #24

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.

Actions #25

Updated by liaham 7 months ago

  • Parent task changed from #2227 to #2189
Actions #26

Updated by liaham 7 months ago

  • Target version changed from 5.1.3 to 6.0.0
Actions

Also available in: Atom PDF