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
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/acidic_job/run.rb', line 45 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
66 67 68 |
# File 'lib/acidic_job/run.rb', line 66 def failed? error_object.present? end |
#finished? ⇒ Boolean
58 59 60 |
# File 'lib/acidic_job/run.rb', line 58 def finished? recovery_point == FINISHED_RECOVERY_POINT end |
#staged_job_id ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/acidic_job/run.rb', line 70 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
62 63 64 |
# File 'lib/acidic_job/run.rb', line 62 def succeeded? finished? && !failed? end |