Class: Workarea::BulkIndexAdmin

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/workarea/bulk_index_admin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.perform(klass, ids) ⇒ Object



8
9
10
11
12
# File 'app/workers/workarea/bulk_index_admin.rb', line 8

def perform(klass, ids)
  ids.each_slice(Workarea.config.bulk_index_batch_size) do |group|
    perform_by_models(klass.constantize.in(id: group).to_a)
  end
end

.perform_by_models(models) ⇒ Object



14
15
16
17
# File 'app/workers/workarea/bulk_index_admin.rb', line 14

def perform_by_models(models)
  return if models.empty?
  Workarea::Search::Admin.bulk(documents_for(models))
end

Instance Method Details

#perform(klass, ids) ⇒ Object



30
31
32
# File 'app/workers/workarea/bulk_index_admin.rb', line 30

def perform(klass, ids)
  self.class.perform(klass, ids)
end