Class: Bulkrax::ImportWorkJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Bulkrax::ImportWorkJob
- Defined in:
- app/jobs/bulkrax/import_work_job.rb
Instance Method Summary collapse
-
#perform(*args) ⇒ Object
rubocop:disable Rails/SkipsModelValidations.
-
#reschedule(entry_id, run_id) ⇒ Object
rubocop:enable Rails/SkipsModelValidations.
Instance Method Details
#perform(*args) ⇒ Object
rubocop:disable Rails/SkipsModelValidations
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/jobs/bulkrax/import_work_job.rb', line 8 def perform(*args) entry = Entry.find(args[0]) entry.build if entry.status == "Complete" ImporterRun.find(args[1]).increment!(:processed_records) ImporterRun.find(args[1]).decrement!(:enqueued_records) unless ImporterRun.find(args[1]).enqueued_records <= 0 # rubocop:disable Style/IdenticalConditionalBranches else # do not retry here because whatever parse error kept you from creating a work will likely # keep preventing you from doing so. ImporterRun.find(args[1]).increment!(:failed_records) ImporterRun.find(args[1]).decrement!(:enqueued_records) unless ImporterRun.find(args[1]).enqueued_records <= 0 # rubocop:disable Style/IdenticalConditionalBranches end entry.save! entry.importer.current_run = ImporterRun.find(args[1]) entry.importer.record_status rescue Bulkrax::CollectionsCreatedError reschedule(args[0], args[1]) end |
#reschedule(entry_id, run_id) ⇒ Object
rubocop:enable Rails/SkipsModelValidations
28 29 30 |
# File 'app/jobs/bulkrax/import_work_job.rb', line 28 def reschedule(entry_id, run_id) ImportWorkJob.set(wait: 1.minute).perform_later(entry_id, run_id) end |