Sha256: 3ebed7ccfd78a55ce36d37fb7032d690bb2929253d811c812702c63ee3e0321b

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

module Delayed
  module Backend
    module ActiveRecord
      class Job < ::ActiveRecord::Base
        def self.reserve(worker, max_run_time = Worker.max_run_time)
          # 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
          unless worker.split_group_id
            ready_scope = ready_scope.where(queue: Worker.queues) if Worker.queues.any?
          end
          # filter only jobs with worker job group id
          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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dj_split-1.1.1 lib/dj_split/dj_activerecord_overrides.rb
dj_split-1.0.1 lib/dj_split/dj_activerecord_overrides.rb
dj_split-1.0.0 lib/dj_split/dj_activerecord_overrides.rb