Class: Bulkrax::ImporterJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/bulkrax/importer_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(importer_id, only_updates_since_last_import = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/jobs/bulkrax/importer_job.rb', line 7

def perform(importer_id, only_updates_since_last_import = false)
  importer = Importer.find(importer_id)
  return schedule(importer, Time.zone.now + 3.minutes, 'Rescheduling: cloud files are not ready yet') unless all_files_completed?(importer)

  importer.current_run
  unzip_imported_file(importer.parser)
  import(importer, only_updates_since_last_import)
  update_current_run_counters(importer)
  schedule(importer) if importer.schedulable?
rescue ::CSV::MalformedCSVError => e
  importer.set_status_info(e)
end