Class: Importo::ImportJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Importo::ImportJob
- Includes:
- GoodJob::ActiveJobExtensions::Batches
- Defined in:
- app/jobs/importo/import_job.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.execute_row(attributes, index, import_id, last_attempt) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/jobs/importo/import_job.rb', line 11 def self.execute_row(attributes, index, import_id, last_attempt) attributes = JSON.load(attributes).deep_symbolize_keys if attributes.is_a?(String) import = Import.find(import_id) import.importer.process_data_row(attributes, index, last_attempt: last_attempt) # Between sidekiq and good job, there's a big difference: # - Sidekiq calls on_complete callback when all jobs ran at least once. # - GoodJob calls on_complete callback when all jobs are done (including retries). # i.e. this logic is only needed for sidekiq # if Importo.config.batch_adapter == Importo::SidekiqBatchAdapter # batch = Importo::SidekiqBatchAdapter.find(bid) # if !import.completed? && import.can_complete? && batch.finished? # ImportJobCallback.new.on_complete("success", {import_id: import.id}) # end # end end |
Instance Method Details
#perform(attributes, index, import_id) ⇒ Object
7 8 9 |
# File 'app/jobs/importo/import_job.rb', line 7 def perform(attributes, index, import_id) self.class.execute_row(attributes, index, import_id, false) end |