Sha256: 7dfd7225b10746a1c65fdb36a81f22630935e3b79f955d6ead87075be072911e
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
module Massive module Status extend ActiveSupport::Concern included do field :started_at, type: Time field :finished_at, type: Time field :failed_at, type: Time field :cancelled_at, type: Time field :last_error, type: String field :retries, type: Integer, default: 0 scope :started, -> { ne(started_at: nil) } scope :not_started, -> { where(started_at: nil) } scope :completed, -> { ne(finished_at: nil) } scope :not_completed, -> { where(finished_at: nil) } scope :failed, -> { ne(failed_at: nil) } scope :cancelled, -> { ne(cancelled_at: nil) } end def start! update_attributes(attributes_to_reset) end def started? !failed? && started_at? end def completed? !failed? && finished_at? end def failed? failed_at? end def enqueued? item = Resque.peek(self.class.queue) item.present? && (item["class"] == self.class.name) && (item["args"] == args_for_resque) end protected def attributes_to_reset { started_at: Time.now, finished_at: nil, failed_at: nil, cancelled_at: nil, retries: 0, last_error: nil } end def args_for_resque end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
massive-0.4.0 | lib/massive/status.rb |
massive-0.3.0 | lib/massive/status.rb |
massive-0.2.0 | lib/massive/status.rb |