Sha256: 73469e6b5c1f73a933d4d976273832dcfca3533dfb1f9c2d5bf600af79b0a4b1

Contents?: true

Size: 701 Bytes

Versions: 68

Compression:

Stored size: 701 Bytes

Contents

class MoveToStatuses < ActiveRecord::Migration[5.1]
  def change
    Bulkrax::Importer.find_each do |i|
      add_status(i)
    end

    Bulkrax::Exporter.find_each do |i|
      add_status(i)
    end

    Bulkrax::Entry.find_each do |i|
      add_status(i)
    end
  end

  def add_status(i)
    return if i.statuses.present?
    if i.last_error
      i.statuses.create(
        status_message: 'Failed',
        runnable: i.last_run,
        error_class: i.last_error['error_class'],
        error_message: i.last_error['error_message'],
        error_backtrace: i.last_error['error_trace']
      )
    else
      i.statuses.create(status_message: 'Complete', runnable: i.last_run)
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
bulkrax-2.1.1 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-2.1.0 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-2.0.2 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-2.0.1 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-2.0.0 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-1.0.2 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-1.0.1 db/migrate/20200819054016_move_to_statuses.rb
bulkrax-1.0.0 db/migrate/20200819054016_move_to_statuses.rb