From c9bfcd5d155e1ce47221f44a66253e09111f85ae Mon Sep 17 00:00:00 2001 From: Romi Hartanto Date: Sat, 14 Aug 2021 14:42:54 +1000 Subject: [PATCH] Forked to add commit for exclude queue functionality https://github.com/collectiveidea/delayed_job_active_record/pull/151 --- lib/delayed/backend/active_record.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/delayed/backend/active_record.rb b/lib/delayed/backend/active_record.rb index 62b186a1..db64344a 100644 --- a/lib/delayed/backend/active_record.rb +++ b/lib/delayed/backend/active_record.rb @@ -41,7 +41,16 @@ class Job < ::ActiveRecord::Base scope :by_priority, lambda { order("priority ASC, run_at ASC") } scope :min_priority, lambda { where("priority >= ?", Worker.min_priority) if Worker.min_priority } scope :max_priority, lambda { where("priority <= ?", Worker.max_priority) if Worker.max_priority } - scope :for_queues, lambda { |queues = Worker.queues| where(queue: queues) if Array(queues).any? } + scope :for_queues, lambda { |queues = Worker.queues| + if Array(queues).any? + if Worker.try(:exclude_specified_queues) + queue_column = arel_table[:queue] + where(queue_column.not_in(queues).or(queue_column.eq nil)) + else + where(queue: queues) + end + end + } before_save :set_default_run_at