Class: Spotlight::AddUploadsFromCsv
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Spotlight::AddUploadsFromCsv
- Includes:
- JobTracking
- Defined in:
- app/jobs/spotlight/add_uploads_from_csv.rb
Overview
Process a CSV upload into new Spotlight::Resource::Upload objects
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
Methods included from JobTracking
#finalize_job_tracker!, #initialize_job_tracker!, #job_tracker, #mark_job_as_failed!
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
10 11 12 |
# File 'app/jobs/spotlight/add_uploads_from_csv.rb', line 10 def count @count end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
10 11 12 |
# File 'app/jobs/spotlight/add_uploads_from_csv.rb', line 10 def errors @errors end |
Instance Method Details
#perform(csv_data, exhibit, _user) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/jobs/spotlight/add_uploads_from_csv.rb', line 23 def perform(csv_data, exhibit, _user) @count = 0 @errors = {} resources(csv_data, exhibit).each_with_index do |resource, index| if resource.save_and_index @count += 1 else @errors[index + 1] = resource.errors. + resource.upload&.errors&. end end end |