Class: Integrations::Propagation::BulkUpdateService

Inherits:
Object
  • Object
show all
Includes:
BulkOperationHashes
Defined in:
app/services/integrations/propagation/bulk_update_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(integration, batch) ⇒ BulkUpdateService

Returns a new instance of BulkUpdateService.



8
9
10
11
# File 'app/services/integrations/propagation/bulk_update_service.rb', line 8

def initialize(integration, batch)
  @integration = integration
  @batch = batch
end

Instance Method Details

#executeObject

rubocop: disable CodeReuse/ActiveRecord



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/integrations/propagation/bulk_update_service.rb', line 14

def execute
  Integration.transaction do
    Integration.where(id: batch_ids).update_all(integration_hash(:update))

    if integration.data_fields_present?
      integration.data_fields.class.where(data_fields_foreign_key => batch_ids)
        .update_all(
          data_fields_hash(:update)
        )
    end

    if integration.is_a?(GitlabSlackApplication) &&
        Feature.enabled?(:gitlab_for_slack_app_instance_and_group_level, type: :beta)
      if integration.active? # rubocop: disable Cop/LineBreakAroundConditionalBlock -- Misidentified
        bulk_update_slack_integrations
      else
        bulk_delete_slack_integrations
      end
    end
  end
end