2020-09-29 11:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PropagateIntegrationGroupWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-07-21 08:09:35 -04:00
|
|
|
data_consistency :always
|
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
|
2021-07-26 14:09:51 -04:00
|
|
|
urgency :low
|
|
|
|
|
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
|
|
|
|
|
2021-04-26 05:09:53 -04:00
|
|
|
batch = if integration.instance_level?
|
2020-10-06 20:08:24 -04:00
|
|
|
Group.where(id: min_id..max_id).without_integration(integration)
|
|
|
|
else
|
|
|
|
integration.group.descendants.where(id: min_id..max_id).without_integration(integration)
|
|
|
|
end
|
|
|
|
|
|
|
|
return if batch.empty?
|
2020-09-29 11:10:08 -04:00
|
|
|
|
|
|
|
BulkCreateIntegrationService.new(integration, batch, 'group').execute
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|