Sha256: 7c2d821e65fa93d5d792a62bc07d312837c2ffd5d44fe39b1381ef0ce0e40206

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

module Searchkick
  class ProcessQueueJob < ActiveJob::Base
    queue_as :searchkick

    def perform(class_name:)
      model = class_name.constantize

      limit = 1000
      record_ids = Searchkick::ReindexQueue.new(model.searchkick_index.name).reserve(limit: limit)
      if record_ids.any?
        Searchkick::ProcessBatchJob.perform_later(
          class_name: model.name,
          record_ids: record_ids
        )
        # TODO when moving to reliable queuing, mark as complete

        if record_ids.size == limit
          Searchkick::ProcessQueueJob.perform_later(class_name: class_name)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
searchkick-2.0.4 lib/searchkick/process_queue_job.rb