summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-03-17 15:17:48 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-03-17 15:17:48 +0000
commit24e99f8b22339e4ffa73af47070092d56ed68229 (patch)
tree302d105976197060236a248823b024943aa994ec /app/models
parent38b3e045cf221e8d1aad1ea7fd9e2a86ea0ff5f6 (diff)
downloadredmine-24e99f8b22339e4ffa73af47070092d56ed68229.tar.gz
redmine-24e99f8b22339e4ffa73af47070092d56ed68229.zip
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11642 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue.rb26
1 files changed, 7 insertions, 19 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 3b4c79def..2e7732089 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -853,28 +853,16 @@ class Issue < ActiveRecord::Base
IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
end
+ # Returns all the other issues that depend on the issue
def all_dependent_issues(except=[])
except << self
dependencies = []
- relations_from.each do |relation|
- if relation.issue_to && !except.include?(relation.issue_to)
- dependencies << relation.issue_to
- dependencies += relation.issue_to.all_dependent_issues(except)
- end
- end
- unless leaf?
- children.each do |child|
- if !except.include?(child)
- dependencies << child
- dependencies += child.all_dependent_issues(except)
- end
- end
- end
- if parent && !except.include?(parent)
- dependencies << parent
- dependencies += parent.all_dependent_issues(except)
- end
- dependencies
+ dependencies += relations_from.map(&:issue_to)
+ dependencies += children unless leaf?
+ dependencies << parent
+ dependencies.compact!
+ dependencies -= except
+ dependencies + dependencies.map {|issue| issue.all_dependent_issues(except)}.flatten
end
# Returns an array of issues that duplicate this one