Method: Delayed::Backend::ActiveRecord::Job.find_available
- Defined in:
- lib/delayed/backend/active_record.rb
.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_time) ⇒ Object
Find a few candidate jobs to run (in case some immediately get locked by others).
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/delayed/backend/active_record.rb', line 43 def self.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_time) scope = self.ready_to_run(worker_name, max_run_time) scope = scope.scoped(:conditions => ['priority >= ?', Worker.min_priority]) if Worker.min_priority scope = scope.scoped(:conditions => ['priority <= ?', Worker.max_priority]) if Worker.max_priority scope = scope.scoped(:conditions => ["queue IN (?)", Worker.queues]) if Worker.queues.any? ::ActiveRecord::Base.silence do scope.by_priority.all(:limit => limit) end end |