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/services/admin/propagate_integration_service.rb')
-rw-r--r--app/services/admin/propagate_integration_service.rb47
1 files changed, 26 insertions, 21 deletions
diff --git a/app/services/admin/propagate_integration_service.rb b/app/services/admin/propagate_integration_service.rb
index 96a6d861e47..ddd5add42bd 100644
--- a/app/services/admin/propagate_integration_service.rb
+++ b/app/services/admin/propagate_integration_service.rb
@@ -5,12 +5,12 @@ module Admin
include PropagateService
def propagate
- update_inherited_integrations
-
if integration.instance?
- create_integration_for_groups_without_integration if Feature.enabled?(:group_level_integrations)
+ update_inherited_integrations
+ create_integration_for_groups_without_integration if Feature.enabled?(:group_level_integrations, default_enabled: true)
create_integration_for_projects_without_integration
else
+ update_inherited_descendant_integrations
create_integration_for_groups_without_integration_belonging_to_group
create_integration_for_projects_without_integration_belonging_to_group
end
@@ -18,34 +18,39 @@ module Admin
private
- # rubocop: disable Cop/InBatches
def update_inherited_integrations
- Service.by_type(integration.type).inherit_from_id(integration.id).in_batches(of: BATCH_SIZE) do |services|
- min_id, max_id = services.pick("MIN(services.id), MAX(services.id)")
- PropagateIntegrationInheritWorker.perform_async(integration.id, min_id, max_id)
- end
+ propagate_integrations(
+ Service.by_type(integration.type).inherit_from_id(integration.id),
+ PropagateIntegrationInheritWorker
+ )
+ end
+
+ def update_inherited_descendant_integrations
+ propagate_integrations(
+ Service.inherited_descendants_from_self_or_ancestors_from(integration),
+ PropagateIntegrationInheritDescendantWorker
+ )
end
- # rubocop: enable Cop/InBatches
def create_integration_for_groups_without_integration
- Group.without_integration(integration).each_batch(of: BATCH_SIZE) do |groups|
- min_id, max_id = groups.pick("MIN(namespaces.id), MAX(namespaces.id)")
- PropagateIntegrationGroupWorker.perform_async(integration.id, min_id, max_id)
- end
+ propagate_integrations(
+ Group.without_integration(integration),
+ PropagateIntegrationGroupWorker
+ )
end
def create_integration_for_groups_without_integration_belonging_to_group
- integration.group.descendants.without_integration(integration).each_batch(of: BATCH_SIZE) do |groups|
- min_id, max_id = groups.pick("MIN(namespaces.id), MAX(namespaces.id)")
- PropagateIntegrationGroupWorker.perform_async(integration.id, min_id, max_id)
- end
+ propagate_integrations(
+ integration.group.descendants.without_integration(integration),
+ PropagateIntegrationGroupWorker
+ )
end
def create_integration_for_projects_without_integration_belonging_to_group
- Project.without_integration(integration).in_namespace(integration.group.self_and_descendants).each_batch(of: BATCH_SIZE) do |projects|
- min_id, max_id = projects.pick("MIN(projects.id), MAX(projects.id)")
- PropagateIntegrationProjectWorker.perform_async(integration.id, min_id, max_id)
- end
+ propagate_integrations(
+ Project.without_integration(integration).in_namespace(integration.group.self_and_descendants),
+ PropagateIntegrationProjectWorker
+ )
end
end
end