Class: Esse::AsyncIndexing::Actions::ImportBatchId

Inherits:
Object
  • Object
show all
Defined in:
lib/esse/async_indexing/actions/import_batch_id.rb

Class Method Summary collapse

Class Method Details

.call(index_class_name, repo_name, batch_id, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/esse/async_indexing/actions/import_batch_id.rb', line 5

def self.call(index_class_name, repo_name, batch_id, options = {})
  _index_class, repo_class = CoerceIndexRepository.call(index_class_name, repo_name)
  queue = Esse::RedisStorage::Queue.for(repo: repo_class)

  kwargs = Esse::HashUtils.deep_transform_keys(options, &:to_sym)
  kwargs[:context] ||= {}
  result = 0
  ids_from_batch = []
  queue.fetch(batch_id) do |ids|
    ids_from_batch = ids
    kwargs[:context][:id] = ids
    result = repo_class.import(**kwargs)
  end
  [result, ids_from_batch]
end