2021-01-03 14:25:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PropagateIntegrationGroupWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :integrations
|
2021-06-08 01:23:25 +05:30
|
|
|
tags :exclude_from_kubernetes
|
2021-01-03 14:25:43 +05:30
|
|
|
idempotent!
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
def perform(integration_id, min_id, max_id)
|
2021-06-08 01:23:25 +05:30
|
|
|
integration = Integration.find_by_id(integration_id)
|
2021-01-03 14:25:43 +05:30
|
|
|
return unless integration
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
batch = if integration.instance_level?
|
2021-01-03 14:25:43 +05:30
|
|
|
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?
|
|
|
|
|
|
|
|
BulkCreateIntegrationService.new(integration, batch, 'group').execute
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|