Class: AcidicJob::Run
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AcidicJob::Run
- Includes:
- GlobalID::Identification
- Defined in:
- lib/acidic_job/run.rb
Constant Summary collapse
- FINISHED_RECOVERY_POINT =
"FINISHED"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.purge ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/acidic_job/run.rb', line 44 def self.purge successfully_completed = where( recovery_point: FINISHED_RECOVERY_POINT, error_object: nil ) count = successfully_completed.count return 0 if count.zero? Rails.logger.info("Deleting #{count} successfully completed AcidicJob runs") successfully_completed.delete_all end |
Instance Method Details
#failed? ⇒ Boolean
65 66 67 |
# File 'lib/acidic_job/run.rb', line 65 def failed? error_object.present? end |
#finished? ⇒ Boolean
57 58 59 |
# File 'lib/acidic_job/run.rb', line 57 def finished? recovery_point == FINISHED_RECOVERY_POINT end |
#staged_job_id ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/acidic_job/run.rb', line 69 def staged_job_id # encode the identifier for this record in the job ID # base64 encoding for minimal security global_id = to_global_id.to_s.remove("gid://") encoded_global_id = Base64.encode64(global_id).strip "STG__#{idempotency_key}__#{encoded_global_id}" end |
#succeeded? ⇒ Boolean
61 62 63 |
# File 'lib/acidic_job/run.rb', line 61 def succeeded? finished? && !failed? end |