2020-09-29 15:10:08 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PropagateIntegrationProjectWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2020-09-29 15:10:08 +00:00
|
|
|
feature_category :integrations
|
2021-07-26 18:09:51 +00:00
|
|
|
urgency :low
|
|
|
|
|
2020-09-29 15:10:08 +00:00
|
|
|
idempotent!
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
def perform(integration_id, min_id, max_id)
|
2021-05-12 12:10:24 +00:00
|
|
|
integration = Integration.find_by_id(integration_id)
|
2020-09-29 15:10:08 +00:00
|
|
|
return unless integration
|
|
|
|
|
|
|
|
batch = Project.where(id: min_id..max_id).without_integration(integration)
|
2021-04-26 09:09:53 +00:00
|
|
|
batch = batch.in_namespace(integration.group.self_and_descendants) if integration.group_level?
|
2020-10-07 00:08:24 +00:00
|
|
|
|
|
|
|
return if batch.empty?
|
2020-09-29 15:10:08 +00:00
|
|
|
|
|
|
|
BulkCreateIntegrationService.new(integration, batch, 'project').execute
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|