app/models/good_job/execution.rb in good_job-3.14.2 vs app/models/good_job/execution.rb in good_job-3.15.0

- old
+ new

@@ -1,9 +1,9 @@ # frozen_string_literal: true module GoodJob # ActiveRecord model that represents an +ActiveJob+ job. - class Execution < BaseRecord + class Execution < BaseExecution include Lockable include Filterable include Reportable # Raised if something attempts to execute a previously completed Execution again. @@ -80,18 +80,10 @@ # @param active_job_id [String] # ActiveJob ID # @return [ActiveRecord::Relation] scope :active_job_id, ->(active_job_id) { where(active_job_id: active_job_id) } - # Get executions with given class name - # @!method job_class - # @!scope class - # @param string [String] - # Execution class name - # @return [ActiveRecord::Relation] - scope :job_class, ->(job_class) { where("serialized_params->>'job_class' = ?", job_class) } - # Get executions that have not yet finished (succeeded or discarded). # @!method unfinished # @!scope class # @return [ActiveRecord::Relation] scope :unfinished, -> { where(finished_at: nil) } @@ -117,11 +109,11 @@ # Order executions by created_at, for first-in first-out # @!method creation_ordered # @!scope class # @return [ActiveRecord:Relation] - scope :creation_ordered, -> { order('created_at ASC') } + scope :creation_ordered, -> { order(created_at: :asc) } # Order executions for de-queueing # @!method dequeueing_ordered # @!scope class # @param parsed_queues [Hash] @@ -153,10 +145,10 @@ # Order jobs by scheduled or created (oldest first). # @!method schedule_ordered # @!scope class # @return [ActiveRecord::Relation] - scope :schedule_ordered, -> { order(Arel.sql('COALESCE(scheduled_at, created_at) ASC')) } + scope :schedule_ordered, -> { order(coalesce_scheduled_at_created_at.asc) } # Get Jobs were completed before the given timestamp. If no timestamp is # provided, get all jobs that have been completed. By default, GoodJob # destroys jobs after they are completed and this will find no jobs. # However, if you have changed {GoodJob.preserve_job_records}, this may