2020-09-29 11:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PropagateIntegrationProjectWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-04-30 14:10:09 -04:00
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2020-09-29 11:10:08 -04:00
|
|
|
feature_category :integrations
|
2021-05-03 05:10:02 -04:00
|
|
|
tags :exclude_from_kubernetes
|
2020-09-29 11:10:08 -04:00
|
|
|
idempotent!
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
def perform(integration_id, min_id, max_id)
|
2021-05-12 08:10:24 -04:00
|
|
|
integration = Integration.find_by_id(integration_id)
|
2020-09-29 11:10:08 -04:00
|
|
|
return unless integration
|
|
|
|
|
|
|
|
batch = Project.where(id: min_id..max_id).without_integration(integration)
|
2021-04-26 05:09:53 -04:00
|
|
|
batch = batch.in_namespace(integration.group.self_and_descendants) if integration.group_level?
|
2020-10-06 20:08:24 -04:00
|
|
|
|
|
|
|
return if batch.empty?
|
2020-09-29 11:10:08 -04:00
|
|
|
|
|
|
|
BulkCreateIntegrationService.new(integration, batch, 'project').execute
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|