Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/namespaces/traversal/linear_scopes.rb')
-rw-r--r--app/models/namespaces/traversal/linear_scopes.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/app/models/namespaces/traversal/linear_scopes.rb b/app/models/namespaces/traversal/linear_scopes.rb
index 9f0f49e729c..09d69a5f77a 100644
--- a/app/models/namespaces/traversal/linear_scopes.rb
+++ b/app/models/namespaces/traversal/linear_scopes.rb
@@ -12,7 +12,7 @@ module Namespaces
def as_ids
return super unless use_traversal_ids?
- select('namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id')
+ select(Arel.sql('namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)]').as('id'))
end
def roots
@@ -53,7 +53,7 @@ module Namespaces
end
def self_and_descendants(include_self: true)
- return super unless use_traversal_ids?
+ return super unless use_traversal_ids_for_descendants_scopes?
if Feature.enabled?(:traversal_ids_btree, default_enabled: :yaml)
self_and_descendants_with_comparison_operators(include_self: include_self)
@@ -65,7 +65,7 @@ module Namespaces
end
def self_and_descendant_ids(include_self: true)
- return super unless use_traversal_ids?
+ return super unless use_traversal_ids_for_descendants_scopes?
if Feature.enabled?(:traversal_ids_btree, default_enabled: :yaml)
self_and_descendants_with_comparison_operators(include_self: include_self).as_ids
@@ -75,6 +75,12 @@ module Namespaces
end
end
+ def self_and_hierarchy
+ return super unless use_traversal_ids_for_self_and_hierarchy_scopes?
+
+ unscoped.from_union([all.self_and_ancestors, all.self_and_descendants(include_self: false)])
+ end
+
def order_by_depth(hierarchy_order)
return all unless hierarchy_order
@@ -109,6 +115,16 @@ module Namespaces
use_traversal_ids?
end
+ def use_traversal_ids_for_descendants_scopes?
+ Feature.enabled?(:use_traversal_ids_for_descendants_scopes, default_enabled: :yaml) &&
+ use_traversal_ids?
+ end
+
+ def use_traversal_ids_for_self_and_hierarchy_scopes?
+ Feature.enabled?(:use_traversal_ids_for_self_and_hierarchy_scopes, default_enabled: :yaml) &&
+ use_traversal_ids?
+ end
+
def self_and_descendants_with_comparison_operators(include_self: true)
base = all.select(
:traversal_ids,