Class: BulkUpdateIntegrationService

Inherits:
Object
  • Object
show all
Includes:
Integrations::BulkOperationHashes
Defined in:
app/services/bulk_update_integration_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(integration, batch) ⇒ BulkUpdateIntegrationService

Returns a new instance of BulkUpdateIntegrationService.



6
7
8
9
# File 'app/services/bulk_update_integration_service.rb', line 6

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

Instance Method Details

#executeObject

rubocop: disable CodeReuse/ActiveRecord



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/bulk_update_integration_service.rb', line 12

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
  end
end