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
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-05 00:09:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-05 00:09:04 +0300
commit155fb78b9a3017640b527bc41c9096642ca11aca (patch)
tree56a8fa90237548d86968da021ccc772245fa7667 /app
parentf5a72705e46f835812ffcc51658eecb08fbdf050 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/feature_flags/components/strategies/flexible_rollout.vue8
-rw-r--r--app/models/namespaces/traversal/linear.rb19
-rw-r--r--app/models/namespaces/traversal/linear_scopes.rb59
-rw-r--r--app/models/namespaces/traversal/recursive.rb1
-rw-r--r--app/models/namespaces/traversal/recursive_scopes.rb25
-rw-r--r--app/models/operations/feature_flags/strategy.rb2
-rw-r--r--app/models/project_feature.rb2
7 files changed, 22 insertions, 94 deletions
diff --git a/app/assets/javascripts/feature_flags/components/strategies/flexible_rollout.vue b/app/assets/javascripts/feature_flags/components/strategies/flexible_rollout.vue
index 4daf8b4e6bf..858c30649bb 100644
--- a/app/assets/javascripts/feature_flags/components/strategies/flexible_rollout.vue
+++ b/app/assets/javascripts/feature_flags/components/strategies/flexible_rollout.vue
@@ -25,19 +25,19 @@ export default {
},
stickinessOptions: [
{
- value: 'DEFAULT',
+ value: 'default',
text: __('Available ID'),
},
{
- value: 'USERID',
+ value: 'userId',
text: __('User ID'),
},
{
- value: 'SESSIONID',
+ value: 'sessionId',
text: __('Session ID'),
},
{
- value: 'RANDOM',
+ value: 'random',
text: __('Random'),
},
],
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb
index 79df466fd64..3d78f384634 100644
--- a/app/models/namespaces/traversal/linear.rb
+++ b/app/models/namespaces/traversal/linear.rb
@@ -37,7 +37,6 @@ module Namespaces
module Traversal
module Linear
extend ActiveSupport::Concern
- include LinearScopes
UnboundedSearch = Class.new(StandardError)
@@ -45,6 +44,14 @@ module Namespaces
before_update :lock_both_roots, if: -> { sync_traversal_ids? && parent_id_changed? }
after_create :sync_traversal_ids, if: -> { sync_traversal_ids? }
after_update :sync_traversal_ids, if: -> { sync_traversal_ids? && saved_change_to_parent_id? }
+
+ scope :traversal_ids_contains, ->(ids) { where("traversal_ids @> (?)", ids) }
+ # When filtering namespaces by the traversal_ids column to compile a
+ # list of namespace IDs, it's much faster to reference the ID in
+ # traversal_ids than the primary key ID column.
+ # WARNING This scope must be used behind a linear query feature flag
+ # such as `use_traversal_ids`.
+ scope :as_ids, -> { select('traversal_ids[array_length(traversal_ids, 1)] AS id') }
end
def sync_traversal_ids?
@@ -157,14 +164,20 @@ module Namespaces
Namespace.lock.select(:id).where(id: roots).order(id: :asc).load
end
+ # Make sure we drop the STI `type = 'Group'` condition for better performance.
+ # Logically equivalent so long as hierarchies remain homogeneous.
+ def without_sti_condition
+ self.class.unscope(where: :type)
+ end
+
# Search this namespace's lineage. Bound inclusively by top node.
def lineage(top: nil, bottom: nil, hierarchy_order: nil)
raise UnboundedSearch, 'Must bound search by either top or bottom' unless top || bottom
- skope = self.class.without_sti_condition
+ skope = without_sti_condition
if top
- skope = skope.where("traversal_ids @> ('{?}')", top.id)
+ skope = skope.traversal_ids_contains("{#{top.id}}")
end
if bottom
diff --git a/app/models/namespaces/traversal/linear_scopes.rb b/app/models/namespaces/traversal/linear_scopes.rb
deleted file mode 100644
index f352497e6de..00000000000
--- a/app/models/namespaces/traversal/linear_scopes.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: true
-
-module Namespaces
- module Traversal
- module LinearScopes
- extend ActiveSupport::Concern
-
- class_methods do
- # When filtering namespaces by the traversal_ids column to compile a
- # list of namespace IDs, it can be faster to reference the ID in
- # traversal_ids than the primary key ID column.
- def as_ids
- return super unless use_traversal_ids?
-
- select('namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id')
- end
-
- def self_and_descendants
- return super unless use_traversal_ids?
-
- without_dups = self_and_descendants_with_duplicates
- .select('DISTINCT on(namespaces.id) namespaces.*')
-
- # Wrap the `SELECT DISTINCT on(....)` with a normal query so we
- # retain expected Rails behavior. Otherwise count and other
- # aggregates won't work.
- unscoped.without_sti_condition.from(without_dups, :namespaces)
- end
-
- def self_and_descendant_ids
- return super unless use_traversal_ids?
-
- self_and_descendants_with_duplicates.select('DISTINCT namespaces.id')
- end
-
- # Make sure we drop the STI `type = 'Group'` condition for better performance.
- # Logically equivalent so long as hierarchies remain homogeneous.
- def without_sti_condition
- unscope(where: :type)
- end
-
- private
-
- def use_traversal_ids?
- Feature.enabled?(:use_traversal_ids, default_enabled: :yaml)
- end
-
- def self_and_descendants_with_duplicates
- base_ids = select(:id)
-
- unscoped
- .without_sti_condition
- .from("namespaces, (#{base_ids.to_sql}) base")
- .where('namespaces.traversal_ids @> ARRAY[base.id]')
- end
- end
- end
- end
-end
diff --git a/app/models/namespaces/traversal/recursive.rb b/app/models/namespaces/traversal/recursive.rb
index c1ada715d6d..d9e8743aa50 100644
--- a/app/models/namespaces/traversal/recursive.rb
+++ b/app/models/namespaces/traversal/recursive.rb
@@ -4,7 +4,6 @@ module Namespaces
module Traversal
module Recursive
extend ActiveSupport::Concern
- include RecursiveScopes
def root_ancestor
return self if parent.nil?
diff --git a/app/models/namespaces/traversal/recursive_scopes.rb b/app/models/namespaces/traversal/recursive_scopes.rb
deleted file mode 100644
index 0dcb23b6567..00000000000
--- a/app/models/namespaces/traversal/recursive_scopes.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-module Namespaces
- module Traversal
- module RecursiveScopes
- extend ActiveSupport::Concern
-
- class_methods do
- def as_ids
- select('id')
- end
-
- def self_and_descendants
- Gitlab::ObjectHierarchy.new(all).base_and_descendants
- end
- alias_method :recursive_self_and_descendants, :self_and_descendants
-
- def self_and_descendant_ids
- self_and_descendants.as_ids
- end
- alias_method :recursive_self_and_descendant_ids, :self_and_descendant_ids
- end
- end
- end
-end
diff --git a/app/models/operations/feature_flags/strategy.rb b/app/models/operations/feature_flags/strategy.rb
index c70e10c72d5..ed9400dde8f 100644
--- a/app/models/operations/feature_flags/strategy.rb
+++ b/app/models/operations/feature_flags/strategy.rb
@@ -16,7 +16,7 @@ module Operations
STRATEGY_USERWITHID => ['userIds'].freeze
}.freeze
USERID_MAX_LENGTH = 256
- STICKINESS_SETTINGS = %w[DEFAULT USERID SESSIONID RANDOM].freeze
+ STICKINESS_SETTINGS = %w[default userId sessionId random].freeze
self.table_name = 'operations_strategies'
diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb
index 94db683267d..11dd10007e9 100644
--- a/app/models/project_feature.rb
+++ b/app/models/project_feature.rb
@@ -79,7 +79,7 @@ class ProjectFeature < ApplicationRecord
end
end
- default_value_for(:container_registry_access_level, allows_nil: false) do |feature|
+ default_value_for(:container_registry_access_level) do |feature|
if gitlab_config_features.container_registry
ENABLED
else