Module: Bulkrax::StatusInfo

Extended by:
ActiveSupport::Concern
Included in:
Entry, Exporter, Importer, PendingRelationship
Defined in:
app/models/concerns/bulkrax/status_info.rb

Instance Method Summary collapse

Instance Method Details

#current_statusObject



19
20
21
22
# File 'app/models/concerns/bulkrax/status_info.rb', line 19

def current_status
  last_status = self.statuses.last
  last_status if last_status && last_status.runnable == last_run
end

#failed?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/concerns/bulkrax/status_info.rb', line 24

def failed?
  current_status&.status_message&.eql?('Failed')
end

#last_errorObject

api compatible with previous error structure



60
61
62
63
64
65
66
67
# File 'app/models/concerns/bulkrax/status_info.rb', line 60

def last_error
  return unless current_status && current_status.error_class.present?
  {
    error_class: current_status.error_class,
    error_message: current_status.error_message,
    error_trace: current_status.error_backtrace
  }.with_indifferent_access
end

#set_status_info(e = nil, current_run = nil) ⇒ Object Also known as: status_info



44
45
46
47
48
49
50
51
52
53
# File 'app/models/concerns/bulkrax/status_info.rb', line 44

def set_status_info(e = nil, current_run = nil)
  runnable = current_run || last_run
  if e.nil?
    self.statuses.create!(status_message: 'Complete', runnable: runnable)
  elsif e.is_a?(String)
    self.statuses.create!(status_message: e, runnable: runnable)
  else
    self.statuses.create!(status_message: 'Failed', runnable: runnable, error_class: e.class.to_s, error_message: e.message, error_backtrace: e.backtrace)
  end
end

#skipped?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/concerns/bulkrax/status_info.rb', line 32

def skipped?
  current_status&.status_message&.match('Skipped')
end

#statusObject



36
37
38
# File 'app/models/concerns/bulkrax/status_info.rb', line 36

def status
  current_status&.status_message || 'Pending'
end

#status_atObject



40
41
42
# File 'app/models/concerns/bulkrax/status_info.rb', line 40

def status_at
  current_status&.created_at
end

#succeeded?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/concerns/bulkrax/status_info.rb', line 28

def succeeded?
  current_status&.status_message&.match(/^Complete$/)
end