diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/models/namespaces/traversal | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/models/namespaces/traversal')
-rw-r--r-- | app/models/namespaces/traversal/recursive.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/app/models/namespaces/traversal/recursive.rb b/app/models/namespaces/traversal/recursive.rb index c46cc521735..d74b7883830 100644 --- a/app/models/namespaces/traversal/recursive.rb +++ b/app/models/namespaces/traversal/recursive.rb @@ -15,8 +15,7 @@ module Namespaces # Returns all ancestors, self, and descendants of the current namespace. def self_and_hierarchy - Gitlab::ObjectHierarchy - .new(self.class.where(id: id)) + object_hierarchy(self.class.where(id: id)) .all_objects end @@ -24,38 +23,38 @@ module Namespaces def ancestors return self.class.none unless parent_id - Gitlab::ObjectHierarchy - .new(self.class.where(id: parent_id)) + object_hierarchy(self.class.where(id: parent_id)) .base_and_ancestors end # returns all ancestors upto but excluding the given namespace # when no namespace is given, all ancestors upto the top are returned def ancestors_upto(top = nil, hierarchy_order: nil) - Gitlab::ObjectHierarchy.new(self.class.where(id: id)) + object_hierarchy(self.class.where(id: id)) .ancestors(upto: top, hierarchy_order: hierarchy_order) end def self_and_ancestors(hierarchy_order: nil) return self.class.where(id: id) unless parent_id - Gitlab::ObjectHierarchy - .new(self.class.where(id: id)) + object_hierarchy(self.class.where(id: id)) .base_and_ancestors(hierarchy_order: hierarchy_order) end # Returns all the descendants of the current namespace. def descendants - Gitlab::ObjectHierarchy - .new(self.class.where(parent_id: id)) + object_hierarchy(self.class.where(parent_id: id)) .base_and_descendants end def self_and_descendants - Gitlab::ObjectHierarchy - .new(self.class.where(id: id)) + object_hierarchy(self.class.where(id: id)) .base_and_descendants end + + def object_hierarchy(ancestors_base) + Gitlab::ObjectHierarchy.new(ancestors_base, options: { use_distinct: Feature.enabled?(:use_distinct_in_object_hierarchy, self) }) + end end end end |