Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.reserve(worker, max_run_time = Worker.max_run_time) # rubocop:disable CyclomaticComplexity
- # scope to filter to records that are "ready to run"
- ready_scope = ready_to_run(worker.name, max_run_time)
- # scope to filter to the single next eligible job
- ready_scope = ready_scope.where("priority >= ?", Worker.min_priority) if Worker.min_priority
- ready_scope = ready_scope.where("priority <= ?", Worker.max_priority) if Worker.max_priority
- ready_scope = ready_scope.where(queue: Worker.queues) if Worker.queues.any?
- ready_scope = ready_scope.by_priority
- reserve_with_scope(ready_scope, worker, db_time_now)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement