summaryrefslogtreecommitdiff
path: root/app/models/namespaces/traversal/recursive_scopes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/namespaces/traversal/recursive_scopes.rb')
-rw-r--r--app/models/namespaces/traversal/recursive_scopes.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/namespaces/traversal/recursive_scopes.rb b/app/models/namespaces/traversal/recursive_scopes.rb
index 6659cefe095..925d9b8bb0c 100644
--- a/app/models/namespaces/traversal/recursive_scopes.rb
+++ b/app/models/namespaces/traversal/recursive_scopes.rb
@@ -10,6 +10,13 @@ module Namespaces
select('id')
end
+ def roots
+ Gitlab::ObjectHierarchy
+ .new(all)
+ .base_and_ancestors
+ .where(namespaces: { parent_id: nil })
+ end
+
def self_and_ancestors(include_self: true, hierarchy_order: nil)
records = Gitlab::ObjectHierarchy.new(all).base_and_ancestors(hierarchy_order: hierarchy_order)