Sha256: e9e580d8710a3ca305bc07782965c1c116209454c7463a88a4f7f851ee8e290c

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Bulkrax
  class ExportWorkJob < ApplicationJob
    queue_as :export

    def perform(*args)
      entry = Entry.find(args[0])
      exporter_run = ExporterRun.find(args[1])
      begin
        entry.build
        entry.save
      rescue StandardError
        # rubocop:disable Rails/SkipsModelValidations
        exporter_run.increment!(:failed_records)
        exporter_run.decrement!(:enqueued_records) unless exporter_run.enqueued_records <= 0
        raise
      else
        if entry.failed?
          exporter_run.increment!(:failed_records)
          exporter_run.decrement!(:enqueued_records) unless exporter_run.enqueued_records <= 0
          raise entry.reload.current_status.error_class.constantize
        else
          exporter_run.increment!(:processed_records)
          exporter_run.decrement!(:enqueued_records) unless exporter_run.enqueued_records <= 0
        end
        # rubocop:enable Rails/SkipsModelValidations
      end
      return entry if exporter_run.enqueued_records.positive?

      if exporter_run.failed_records.positive?
        exporter_run.exporter.set_status_info('Complete (with failures)')
      else
        exporter_run.exporter.set_status_info('Complete')
      end

      return entry
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bulkrax-5.4.2 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.3.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.4.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.4.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.3.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.2.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.2.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.1.0 app/jobs/bulkrax/export_work_job.rb