Sha256: 4c62dd9eb8a3d10e3d138d78579cd19b18efa564602d1424eb479cde2f662767

Contents?: true

Size: 668 Bytes

Versions: 14

Compression:

Stored size: 668 Bytes

Contents

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

    def perform(class_name:)
      model = class_name.constantize

      limit = model.searchkick_index.options[:batch_size] || 1000
      record_ids = model.searchkick_index.reindex_queue.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

14 entries across 14 versions & 2 rubygems

Version Path
searchkick-hooopo-2.4.1 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.4.0 lib/searchkick/process_queue_job.rb
searchkick-2.4.0 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.3.5 lib/searchkick/process_queue_job.rb
searchkick-2.3.2 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.3.4 lib/searchkick/process_queue_job.rb
searchkick-2.3.1 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.3.3 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.3.2 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.3.1 lib/searchkick/process_queue_job.rb
searchkick-hooopo-2.3.0 lib/searchkick/process_queue_job.rb
searchkick-2.3.0 lib/searchkick/process_queue_job.rb
searchkick-2.2.1 lib/searchkick/process_queue_job.rb
searchkick-2.2.0 lib/searchkick/process_queue_job.rb