Class: ImportRunJob
- Inherits:
-
ApplicationJob
- Object
- ApplicationJob
- ImportRunJob
- Defined in:
- app/jobs/import_run_job.rb
Overview
ImportRunJob class
Instance Method Summary collapse
Instance Method Details
#perform(import) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/jobs/import_run_job.rb', line 7 def perform(import) data = CSV.parse(import.csv_file.download, headers: true) data.each do |doc| extract_hash = doc.to_h converted_data = import.convert_data(extract_hash) kithe_document = { title: converted_data[GeoblacklightAdmin::Schema.instance.solr_fields[:title]], json_attributes: converted_data, friendlier_id: converted_data[GeoblacklightAdmin::Schema.instance.solr_fields[:id]], import_id: import.id } # Capture document for import attempt import_document = ImportDocument.create(kithe_document) # Add import document to background job queue ImportDocumentJob.perform_later(import_document) rescue => e logger.debug "\n\nCANNOT IMPORT: #{extract_hash.inspect}" logger.debug "Error: #{e.inspect}\n\n" next end end |