Class: Gitlab::BackgroundMigration::BackfillCodeSuggestionsNamespaceSettings
- Inherits:
-
BatchedMigrationJob
- Object
- BatchedMigrationJob
- Gitlab::BackgroundMigration::BackfillCodeSuggestionsNamespaceSettings
- Defined in:
- lib/gitlab/background_migration/backfill_code_suggestions_namespace_settings.rb
Overview
This class sets default ‘code_suggestions` values on the namespace_settings table. For group namespace, set this to enabled. For user namespace, set this to disabled.
Constant Summary collapse
- TYPE_VALUE_PAIRS =
[ { type: 'Group', value: true }, { type: 'User', value: false } ].freeze
- NAMESPACES_JOIN =
<<~SQL INNER JOIN namespaces ON namespaces.id = namespace_settings.namespace_id SQL
Constants inherited from BatchedMigrationJob
Gitlab::BackgroundMigration::BatchedMigrationJob::DEFAULT_FEATURE_CATEGORY
Constants included from Database::DynamicModelHelpers
Database::DynamicModelHelpers::BATCH_SIZE
Instance Method Summary collapse
Methods inherited from BatchedMigrationJob
#batch_metrics, feature_category, #filter_batch, generic_instance, #initialize, job_arguments, job_arguments_count, operation_name, scope_to
Methods included from Database::DynamicModelHelpers
#define_batchable_model, #each_batch, #each_batch_range
Constructor Details
This class inherits a constructor from Gitlab::BackgroundMigration::BatchedMigrationJob
Instance Method Details
#perform ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/gitlab/background_migration/backfill_code_suggestions_namespace_settings.rb', line 22 def perform TYPE_VALUE_PAIRS.each do |pair| each_sub_batch do |sub_batch| sub_batch.joins(NAMESPACES_JOIN) .where(namespaces: { type: pair[:type] }) .update_all(code_suggestions: pair[:value]) end end end |