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
- #current_status ⇒ Object
- #failed? ⇒ Boolean
-
#last_error ⇒ Object
api compatible with previous error structure.
- #set_status_info(e = nil, current_run = nil) ⇒ Object (also: #status_info)
- #skipped? ⇒ Boolean
- #status ⇒ Object
- #status_at ⇒ Object
- #succeeded? ⇒ Boolean
Instance Method Details
#current_status ⇒ Object
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
24 25 26 |
# File 'app/models/concerns/bulkrax/status_info.rb', line 24 def failed? current_status&.&.eql?('Failed') end |
#last_error ⇒ Object
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_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., error_backtrace: e.backtrace) end end |
#skipped? ⇒ Boolean
32 33 34 |
# File 'app/models/concerns/bulkrax/status_info.rb', line 32 def skipped? current_status&.&.match('Skipped') end |
#status ⇒ Object
36 37 38 |
# File 'app/models/concerns/bulkrax/status_info.rb', line 36 def status current_status&. || 'Pending' end |
#status_at ⇒ Object
40 41 42 |
# File 'app/models/concerns/bulkrax/status_info.rb', line 40 def status_at current_status&.created_at end |
#succeeded? ⇒ Boolean
28 29 30 |
# File 'app/models/concerns/bulkrax/status_info.rb', line 28 def succeeded? current_status&.&.match(/^Complete$/) end |