Sha256: 8e734d5c03dc582d3c15a0155d65d4f4fcb0078512551520ccda61b63c4c328b
Contents?: true
Size: 951 Bytes
Versions: 6
Compression:
Stored size: 951 Bytes
Contents
module Searchkick class ProcessQueueJob < ActiveJob::Base queue_as { Searchkick.queue_name } def perform(class_name:, index_name: nil, inline: false) model = class_name.constantize limit = model.searchkick_options[:batch_size] || 1000 loop do record_ids = model.searchkick_index(name: index_name).reindex_queue.reserve(limit: limit) if record_ids.any? batch_options = { class_name: class_name, record_ids: record_ids.uniq, index_name: index_name } if inline # use new.perform to avoid excessive logging Searchkick::ProcessBatchJob.new.perform(**batch_options) else Searchkick::ProcessBatchJob.perform_later(**batch_options) end # TODO when moving to reliable queuing, mark as complete end break unless record_ids.size == limit end end end end
Version data entries
6 entries across 6 versions & 1 rubygems