5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/dj_split/dj_activerecord_overrides.rb', line 5
def self.reserve(worker, max_run_time = Worker.max_run_time)
ready_scope = ready_to_run(worker.name, max_run_time)
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
unless worker.split_group_id
ready_scope = ready_scope.where(queue: Worker.queues) if Worker.queues.any?
end
ready_scope = ready_scope.where(split_group_id: worker.split_group_id) if worker.split_group_id
ready_scope = ready_scope.by_priority
reserve_with_scope(ready_scope, worker, db_time_now)
end
|