Class: BulkUpdateIntegrationService

Inherits:
Object
  • Object
show all
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.


4
5
6
7
# File 'app/services/bulk_update_integration_service.rb', line 4

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

Instance Method Details

#executeObject

rubocop: disable CodeReuse/ActiveRecord


10
11
12
13
14
15
16
17
18
# File 'app/services/bulk_update_integration_service.rb', line 10

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

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