Class: Bulkrax::ImportCollectionJob

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

Instance Method Summary collapse

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
# File 'app/jobs/bulkrax/import_collection_job.rb', line 8

def perform(*args)
  entry = Entry.find(args[0])
  begin
    entry.build
    entry.save!
    ImporterRun.increment_counter(:processed_records, args[1])
    ImporterRun.increment_counter(:processed_collections, args[1])
    ImporterRun.decrement_counter(:enqueued_records, args[1]) unless ImporterRun.find(args[1]).enqueued_records <= 0 # rubocop:disable Style/IdenticalConditionalBranches
  rescue => e
    ImporterRun.increment_counter(:failed_records, args[1])
    ImporterRun.increment_counter(:failed_collections, args[1])
    ImporterRun.decrement_counter(:enqueued_records, args[1]) unless ImporterRun.find(args[1]).enqueued_records <= 0 # rubocop:disable Style/IdenticalConditionalBranches
    raise e
  end
  entry.importer.current_run = ImporterRun.find(args[1])
  entry.importer.record_status
end