summaryrefslogtreecommitdiff
path: root/app/services/concerns/admin/propagate_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/concerns/admin/propagate_service.rb')
-rw-r--r--app/services/concerns/admin/propagate_service.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/services/concerns/admin/propagate_service.rb b/app/services/concerns/admin/propagate_service.rb
index 065ab6f7ff9..03e422aec54 100644
--- a/app/services/concerns/admin/propagate_service.rb
+++ b/app/services/concerns/admin/propagate_service.rb
@@ -21,9 +21,16 @@ module Admin
attr_reader :integration
def create_integration_for_projects_without_integration
- Project.without_integration(integration).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)
+ propagate_integrations(
+ Project.without_integration(integration),
+ PropagateIntegrationProjectWorker
+ )
+ end
+
+ def propagate_integrations(relation, worker_class)
+ relation.each_batch(of: BATCH_SIZE) do |records|
+ min_id, max_id = records.pick("MIN(#{relation.table_name}.id), MAX(#{relation.table_name}.id)")
+ worker_class.perform_async(integration.id, min_id, max_id)
end
end
end