Sha256: b3580f4c0d50f4e15d1fb99617fc62ff95e6a63dd90b41cc9bb6dd11ce81a4bd

Contents?: true

Size: 866 Bytes

Versions: 33

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

module Delayed
  module Jobs
    #
    # Single execution of a Job
    #
    class Run
      include StandardModel
      #
      # Fields
      #
      field :name, type: String
      field :locked_at, type: Time
      field :locked_by, type: String
      field :duration, type: Float, default: 0
      #
      # Relationships
      #
      belongs_to :worker, class_name: 'Delayed::Jobs::Worker'
      #
      # Validations
      #
      validates :name, presence: true
      validates :locked_at, presence: true
      validates :duration, numericality: { greater_than_or_equal_to: 0 }
      #
      # Callbacks
      #
      before_validation :record_duration

      #
      # Finish execution
      #
      def record_duration
        self.duration = duration.zero? ? Time.now.utc - locked_at : duration
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
web47core-3.2.20 lib/app/models/delayed/jobs/run.rb
web47core-3.2.19 lib/app/models/delayed/jobs/run.rb
web47core-3.2.18 lib/app/models/delayed/jobs/run.rb
web47core-3.2.17 lib/app/models/delayed/jobs/run.rb
web47core-3.2.16 lib/app/models/delayed/jobs/run.rb
web47core-3.2.15 lib/app/models/delayed/jobs/run.rb
web47core-3.2.14 lib/app/models/delayed/jobs/run.rb
web47core-3.2.13 lib/app/models/delayed/jobs/run.rb
web47core-3.2.12 lib/app/models/delayed/jobs/run.rb
web47core-3.2.9 lib/app/models/delayed/jobs/run.rb
web47core-3.2.8 lib/app/models/delayed/jobs/run.rb
web47core-3.2.7 lib/app/models/delayed/jobs/run.rb
web47core-3.2.6 lib/app/models/delayed/jobs/run.rb
web47core-3.2.5 lib/app/models/delayed/jobs/run.rb
web47core-3.2.4 lib/app/models/delayed/jobs/run.rb
web47core-2.2.20 lib/app/models/delayed/jobs/run.rb
web47core-2.2.19 lib/app/models/delayed/jobs/run.rb
web47core-3.2.3 lib/app/models/delayed/jobs/run.rb
web47core-3.2.2 lib/app/models/delayed/jobs/run.rb
web47core-2.2.15 lib/app/models/delayed/jobs/run.rb