|
|
@ -839,7 +839,7 @@ class Project < ActiveRecord::Base
|
|
|
|
# Yields the given block for each project with its level in the tree
|
|
|
|
# Yields the given block for each project with its level in the tree
|
|
|
|
def self.project_tree(projects, &block)
|
|
|
|
def self.project_tree(projects, &block)
|
|
|
|
ancestors = []
|
|
|
|
ancestors = []
|
|
|
|
projects.sort_by(&:lft).each do |project|
|
|
|
|
projects.sort_by(&:id).each do |project|
|
|
|
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
|
|
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
|
|
|
ancestors.pop
|
|
|
|
ancestors.pop
|
|
|
|
end
|
|
|
|
end
|
|
|
|