Commit ad006fd9df5498907b11ddc535db92be2296c9cf

Authored by Andrew Kane
1 parent e09d4473

Changed delete to delete_missing [skip ci]

lib/searchkick/bulk_reindex_job.rb
... ... @@ -2,7 +2,7 @@ module Searchkick
2 2 class BulkReindexJob < ActiveJob::Base
3 3 queue_as :searchkick
4 4  
5   - def perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil, delete: false)
  5 + def perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil, delete_missing: false)
6 6 klass = class_name.constantize
7 7 index = index_name ? Searchkick::Index.new(index_name) : klass.searchkick_index
8 8 record_ids ||= min_id..max_id
... ... @@ -12,7 +12,7 @@ module Searchkick
12 12 method_name: method_name,
13 13 batch: true,
14 14 batch_id: batch_id,
15   - delete: delete,
  15 + delete_missing: delete_missing,
16 16 record_ids: record_ids
17 17 )
18 18 end
... ...
lib/searchkick/index.rb
... ... @@ -247,14 +247,14 @@ module Searchkick
247 247 end
248 248 end
249 249  
250   - def import_scope(scope, resume: false, method_name: nil, async: false, batch: false, batch_id: nil, full: false, delete: false, record_ids: nil)
  250 + def import_scope(scope, resume: false, method_name: nil, async: false, batch: false, batch_id: nil, full: false, delete_missing: false, record_ids: nil)
251 251 batch_size = @options[:batch_size] || 1000
252 252  
253 253 # use scope for import
254 254 scope = scope.search_import if scope.respond_to?(:search_import)
255 255  
256 256 if batch
257   - import_or_update scope.to_a, method_name, async, delete, record_ids, scope.model
  257 + import_or_update scope.to_a, method_name, async, delete_missing, record_ids, scope.model
258 258 Searchkick.redis.srem(batches_key, batch_id) if batch_id && Searchkick.redis
259 259 elsif full && async
260 260 if scope.respond_to?(:primary_key)
... ... @@ -422,7 +422,7 @@ module Searchkick
422 422 end
423 423 end
424 424  
425   - def import_or_update(records, method_name, async, delete = false, record_ids = nil, klass = nil)
  425 + def import_or_update(records, method_name, async, delete_missing = false, record_ids = nil, klass = nil)
426 426 if records.any?
427 427 if async
428 428 Searchkick::BulkReindexJob.perform_later(
... ... @@ -436,7 +436,7 @@ module Searchkick
436 436 records = records.select(&:should_index?)
437 437  
438 438 delete_records =
439   - if delete
  439 + if delete_missing
440 440 # determine which records to delete
441 441 (record_ids - records.map { |r| r.id.to_s }).map { |id| m = klass.new; m.id = id; m }
442 442 else
... ...
lib/searchkick/process_batch_job.rb
... ... @@ -7,7 +7,7 @@ module Searchkick
7 7 Searchkick::BulkReindexJob.perform_now(
8 8 class_name: class_name,
9 9 record_ids: record_ids,
10   - delete: true
  10 + delete_missing: true
11 11 )
12 12 end
13 13 end
... ...