lib/good_job/job.rb in good_job-1.9.3 vs lib/good_job/job.rb in good_job-1.9.4
- old
+ new
@@ -48,10 +48,18 @@
else
{ include: queues }
end
end
+ # Get Jobs with given class name
+ # @!method with_job_class
+ # @!scope class
+ # @param string [String]
+ # Job class name
+ # @return [ActiveRecord::Relation]
+ scope :with_job_class, ->(job_class) { where("serialized_params->>'job_class' = ?", job_class) }
+
# Get Jobs that have not yet been completed.
# @!method unfinished
# @!scope class
# @return [ActiveRecord::Relation]
scope :unfinished, (lambda do
@@ -92,10 +100,16 @@
# @param timestamp (Float)
# Get jobs that finished before this time (in epoch time).
# @return [ActiveRecord::Relation]
scope :finished, ->(timestamp = nil) { timestamp ? where(arel_table['finished_at'].lteq(timestamp)) : where.not(finished_at: nil) }
+ # Get Jobs that started but not finished yet.
+ # @!method running
+ # @!scope class
+ # @return [ActiveRecord::Relation]
+ scope :running, -> { where.not(performed_at: nil).where(finished_at: nil) }
+
# Get Jobs on queues that match the given queue string.
# @!method queue_string(string)
# @!scope class
# @param string [String]
# A string expression describing what queues to select. See
@@ -233,10 +247,10 @@
self.class.unscoped.unfinished.owns_advisory_locked.exists?(id: id)
end
private
- # @return [GoodJob::ExecutionResult]
+ # @return [ExecutionResult]
def execute
params = serialized_params.merge(
"provider_job_id" => id
)