app/models/good_job/execution.rb in good_job-3.21.5 vs app/models/good_job/execution.rb in good_job-3.22.0
- old
+ new
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module GoodJob
- # ActiveRecord model that represents an +ActiveJob+ job.
+ # Active Record model that represents an +ActiveJob+ job.
class Execution < BaseExecution
# Raised if something attempts to execute a previously completed Execution again.
PreviouslyPerformedError = Class.new(StandardError)
# String separating Error Class from Error Message
@@ -148,13 +148,13 @@
# @!method schedule_ordered
# @!scope class
# @return [ActiveRecord::Relation]
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.
+ # Get completed jobs before the given timestamp. If no timestamp is
+ # provided, get *all* completed jobs. By default, GoodJob
+ # destroys jobs after they're completed, meaning this returns no jobs.
# However, if you have changed {GoodJob.preserve_job_records}, this may
# find completed Jobs.
# @!method finished(timestamp = nil)
# @!scope class
# @param timestamp (Float)
@@ -222,9 +222,16 @@
priority: active_job.priority || DEFAULT_PRIORITY,
serialized_params: active_job.serialize,
}
execution_args[:scheduled_at] = Time.zone.at(active_job.scheduled_at) if active_job.scheduled_at
execution_args[:concurrency_key] = active_job.good_job_concurrency_key if active_job.respond_to?(:good_job_concurrency_key)
+
+ if active_job.respond_to?(:good_job_labels) && active_job.good_job_labels.any? && labels_migrated?
+ labels = active_job.good_job_labels.dup
+ labels.map! { |label| label.to_s.strip.presence }
+ labels.tap(&:compact!).tap(&:uniq!)
+ execution_args[:labels] = labels
+ end
reenqueued_current_execution = CurrentThread.active_job_id && CurrentThread.active_job_id == active_job.job_id
current_execution = CurrentThread.execution
if reenqueued_current_execution