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
33
34
35
|
# File 'app/jobs/bulkrax/export_work_job.rb', line 7
def perform(*args)
entry = Entry.find(args[0])
begin
entry.build
entry.save
rescue StandardError
ExporterRun.find(args[1]).increment!(:failed_records)
ExporterRun.find(args[1]).decrement!(:enqueued_records)
raise
else
if entry.failed?
ExporterRun.find(args[1]).increment!(:failed_records)
ExporterRun.find(args[1]).decrement!(:enqueued_records)
raise entry.reload.current_status.error_class.constantize
else
ExporterRun.find(args[1]).increment!(:processed_records)
ExporterRun.find(args[1]).decrement!(:enqueued_records)
end
end
exporter_run = ExporterRun.find(args[1])
return if exporter_run.enqueued_records.positive?
if exporter_run.failed_records.positive?
exporter_run.exporter.status_info('Complete (with failures)')
else
exporter_run.exporter.status_info('Complete')
end
end
|