Sha256: d11919c50b48715569195a62dc3de96c359086053babeebc15b0b586d7ac8cb5

Contents?: true

Size: 682 Bytes

Versions: 13

Compression:

Stored size: 682 Bytes

Contents

module Searchkick
  class ProcessQueueJob < ActiveJob::Base
    queue_as { Searchkick.queue_name }

    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

13 entries across 13 versions & 2 rubygems

Version Path
searchkick-4.0.2 lib/searchkick/process_queue_job.rb
searchkick-4.0.1 lib/searchkick/process_queue_job.rb
searchkick-4.0.0 lib/searchkick/process_queue_job.rb
searchkick-3.1.3 lib/searchkick/process_queue_job.rb
searchkick-3.1.2 lib/searchkick/process_queue_job.rb
searchkick-3.1.1 lib/searchkick/process_queue_job.rb
searchkick-3.1.0 lib/searchkick/process_queue_job.rb
searchkick-3.0.3 lib/searchkick/process_queue_job.rb
searchkick_evichat-0.0.2 lib/searchkick/process_queue_job.rb
searchkick-3.0.2 lib/searchkick/process_queue_job.rb
searchkick-3.0.1 lib/searchkick/process_queue_job.rb
searchkick-3.0.0 lib/searchkick/process_queue_job.rb
searchkick-2.5.0 lib/searchkick/process_queue_job.rb