Sha256: 488cc3bfc15a1bd9c3ab226e7d83511db457cc800ba59859d5ab0c1ed3b55c36

Contents?: true

Size: 1.25 KB

Versions: 14

Compression:

Stored size: 1.25 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.status_info('Complete (with failures)')
      else
        exporter_run.exporter.status_info('Complete')
      end

      return entry
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bulkrax-4.4.2 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.4.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.3.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-5.0.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.4.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.3.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.2.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.2.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.1.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.1.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-4.0.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-3.5.1 app/jobs/bulkrax/export_work_job.rb
bulkrax-3.5.0 app/jobs/bulkrax/export_work_job.rb
bulkrax-3.4.0 app/jobs/bulkrax/export_work_job.rb