Project

General

Profile

To do #1508

issue_patch : Optimize update_parent_pbi_on_closed_tasks

Added by Redmine Smile over 6 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Estimated time:
Blocked:
No
Milestones:
Sprint:

Description

break if task opened found :

        def update_parent_pbi_on_closed_tasks
          statuses = IssueStatus.where(:id => Scrum::Setting.closed_pbi_status_id).order("position ASC")
          pbi = self.parent
          if statuses.length == 1 and pbi and pbi.is_pbi?
            pbi_status_to_set = statuses.first
            all_tasks_closed = self.closed?
            pbi.children.each do |task|
              if task.is_task?
                task = self if task.id == self.id
                unless task.closed?
                  all_tasks_closed = false
                  break # at least a task opened, no need to go further
                end
              end
            end
            if all_tasks_closed and pbi.status != pbi_status_to_set
              pbi.init_journal(User.current,
                               l(:label_pbi_status_auto_updated_all_tasks_closed,
                                 :pbi_status => pbi_status_to_set.name))
              pbi.status = pbi_status_to_set
              pbi.save!
            end
          end
        end

Also available in: Atom PDF