Sha256: 9999e046ee009683b00bbdbe7cd3b2b765e2a2f7397f09fff726a4011b5b003c
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
module CronoTrigger module Models class Execution < ActiveRecord::Base self.table_name = "crono_trigger_executions" belongs_to :schedule, polymorphic: true, inverse_of: :crono_trigger_executions scope :recently, ->(schedule_type:) { where(schedule_type: schedule_type).order(executed_at: :desc) } if ActiveRecord.version >= Gem::Version.new("7.0") enum :status, { executing: "executing", completed: "completed", failed: "failed", retrying: "retrying", aborted: "aborted", } else enum status: { executing: "executing", completed: "completed", failed: "failed", retrying: "retrying", aborted: "aborted", } end def self.create_with_timestamp! create!(executed_at: Time.current, status: :executing, worker_id: CronoTrigger.config.worker_id) end def complete! update!(status: :completed, completed_at: Time.current) end def error!(exception) update!(status: :failed, completed_at: Time.current, error_name: exception.class.to_s, error_reason: exception.message) end def retry! return false if schedule.locking? schedule.retry! end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crono_trigger-0.8.3 | lib/crono_trigger/models/execution.rb |