Class: LcpRuby::Import::ImportJobHandler

Inherits:
BackgroundJobs::BaseHandler show all
Defined in:
lib/lcp_ruby/import/import_job_handler.rb

Constant Summary collapse

FLUSH_INTERVAL =
100

Instance Attribute Summary

Attributes inherited from BackgroundJobs::BaseHandler

#definition, #execution

Instance Method Summary collapse

Methods inherited from BackgroundJobs::BaseHandler

#attach_result!, #check_cancellation!, #flush_log!, #initialize, #log!, #params, #set_result_url!, #target_record, #triggered_by, #update_progress!

Constructor Details

This class inherits a constructor from LcpRuby::BackgroundJobs::BaseHandler

Instance Method Details

#performObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lcp_ruby/import/import_job_handler.rb', line 6

def perform
  setup_context!
  load_resources!

  log!("Starting import: #{params['total_rows']} rows, strategy: #{@strategy}")

  process_rows!
  flush_buffer!
  finalize!
rescue BackgroundJobs::CancellationError
  flush_buffer!
  log!("Import cancelled by user", level: :warn)
  finalize!(cancelled: true)
end