Class: Searchkick::BulkReindexJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/searchkick/bulk_reindex_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/searchkick/bulk_reindex_job.rb', line 5

def perform(params)
  klass = params["class_name"].constantize
  index_name = params["index_name"]
  record_ids = params["record_ids"]
  method_name = params["method_name"]
  batch_id = params["batch_id"]
  min_id = params["min_id"]
  max_id = params["max_id"]
  index = index_name ? Searchkick::Index.new(index_name, **klass.searchkick_options) : klass.searchkick_index
  record_ids ||= min_id..max_id
  index.import_scope(
    Searchkick.load_records(klass, record_ids),
    method_name: method_name,
    batch: true,
    batch_id: batch_id
  )
end