Defect #5880

Only consider open subtasks when computing the priority of a parent issue

Added by Norbert Bérci over 10 years ago. Updated almost 5 years ago.

Status:ClosedStart date:2010-07-14
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Issues
Target version:3.3.0
Resolution:Fixed Affected version:

Description

When computing the priority of a task, only subtasks with not closed status should be considered.

see http://demo.redmine.org/issues/26174

defect-5880.diff Magnifier - patch against 3.2.0.devel.15058 (2.32 KB) Go MAEDA, 2016-01-14 14:36


Related issues

Related to Redmine - Feature #5490: Option for independent subtask priority/start date/due da... Closed 2010-05-10
Related to Redmine - Defect #6847: Parent priorities not dropping when subtask priorities de... Closed 2010-11-08
Duplicated by Redmine - Feature #13736: Parent priority does not update when subtasks are closed Closed
Duplicated by Redmine - Feature #19921: Issue priority with subtasks : not with closed issues Closed
Duplicated by Redmine - Feature #15289: Recalculate priority of a parent issue automatically afte... Closed
Duplicated by Redmine - Defect #14933: Parent issues default to highest priority child issue, sh... Closed

Associated revisions

Revision 15064
Added by Jean-Philippe Lang almost 5 years ago

Only consider open subtasks when computing the priority of a parent issue (#5880).

Patch by Go MAEDA.

History

#1 Updated by dimitar korudjiiski over 10 years ago

  • % Done changed from 0 to 60

Norbert Bérci wrote:

When computing the priority of a task, only subtasks with not closed status should be considered.

see http://demo.redmine.org/issues/26174

#2 Updated by Norbert Bérci over 10 years ago

set back because previous modifier was using this instead of demo.redmine.org

#3 Updated by Norbert Bérci over 10 years ago

  • % Done changed from 60 to 0

#4 Updated by Ewan Makepeace almost 10 years ago

  1. Agreed.
  2. Also there is no way to tell which of many subtasks is driving the priority.
  3. For example my top priority level is emergency - but when it is a group I cant tell which is the emergency subtask (which might actually be closed!)

#5 Updated by Andreas Bosch almost 10 years ago

+1 - related to #5490 and #6847

Also see my forum post regarding this issue.

#6 Updated by Mischa The Evil almost 9 years ago

  • Subject changed from parent task priority computation to Only consider open subtasks when computing the priority of a parent issue

#7 Updated by Mischa The Evil almost 9 years ago

  • Category set to Issues

#8 Updated by Ross Saad over 7 years ago

+1

#9 Updated by John Pisani over 7 years ago

+1

#10 Updated by Emmanuel Serau over 7 years ago

+1

#11 Updated by Mikołaj Milej about 7 years ago

+10

but, show me the code, I'll create a patch for it (or I'll find the code).

edit:

works for me:
in file: app/models/issue.rb
changed

      # priority = highest priority of children
      if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :joins => :priority)
        p.priority = IssuePriority.find_by_position(priority_position)
      end

to
      # priority = highest priority of children
      if p.children.count > 0
        if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", {:joins => [:priority, :status], :conditions => 'is_closed = 0'})
        else
          priority_position = IssuePriority.where("#{IssuePriority.table_name}.position", :conditions => 'is_default = 1')
        end
        p.priority = IssuePriority.find_by_position(priority_position)
      end

I know almost nothing about Ruby and RoR so there is place for improvements and bug fixes ;]

#12 Updated by A B about 6 years ago

The above patch does not work on db's with proper boolean types such as PostgreSQL; it also has a bug in the else clause in that it returns an IssuePriority object rather than a number. Here's an updated version that should work on all db's and fixes the bug:

      # priority = highest priority of open children
      if p.children.count > 0
        if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", {:joins => [:priority, :status], :conditions => ['is_closed = ?', false]})
        else
          priority_position = IssuePriority.where(is_default: true).pluck(:position).first
        end
        p.priority = IssuePriority.find_by_position(priority_position)
      end

#13 Updated by txemi M almost 6 years ago

+1

I would like to see this implemented.
It is difficult for me get useful task views based on priority with all those already not important parent tasks showing on top.

#14 Updated by Go MAEDA almost 5 years ago

  • Duplicated by Feature #19921: Issue priority with subtasks : not with closed issues added

#15 Updated by Go MAEDA almost 5 years ago

  • Target version set to Candidate for next major release

#16 Updated by Go MAEDA almost 5 years ago

  • Duplicated by Feature #15289: Recalculate priority of a parent issue automatically after child issue is closed added

#17 Updated by Go MAEDA almost 5 years ago

  • Duplicated by Defect #14933: Parent issues default to highest priority child issue, should be highest priority *OPEN* child issue added

#18 Updated by Go MAEDA almost 5 years ago

This is a patch for current trunk (r15058).

Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb    (revision 15058)
+++ app/models/issue.rb    (working copy)
@@ -1451,9 +1451,11 @@
   def recalculate_attributes_for(issue_id)
     if issue_id && p = Issue.find_by_id(issue_id)
       if p.priority_derived?
-        # priority = highest priority of children
-        if priority_position = p.children.joins(:priority).maximum("#{IssuePriority.table_name}.position")
+        # priority = highest priority of open children
+        if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position")
           p.priority = IssuePriority.find_by_position(priority_position)
+        else
+          p.priority = IssuePriority.default
         end
       end

#19 Updated by Go MAEDA almost 5 years ago

  • File defect-5880.diffMagnifier added
  • Target version changed from Candidate for next major release to 3.3.0

Here is a patch with tests: defect-5880.diff
Please consider merging this fix.

#20 Updated by Jean-Philippe Lang almost 5 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Patch committed, thanks.

Also available in: Atom PDF