module Jekyll::Algolia::Indexer
def self.execute_operations(operations)
Note: Will split the batch in several calls if too big, and will display
operations - Operations to batch
Public: Execute a serie of operations in a batch
def self.execute_operations(operations) return if Configurator.dry_run? return if operations.empty? # Run the batches in slices if they are too large batch_size = Configurator.algolia('indexing_batch_size') slices = operations.each_slice(batch_size).to_a should_have_progress_bar = (slices.length > 1) if should_have_progress_bar progress_bar = ProgressBar.create( total: slices.length, format: 'Updating index (%j%%) |%B|' ) end slices.each do |slice| begin ::Algolia.batch!(slice) progress_bar.increment if should_have_progress_bar rescue StandardError => error ErrorHandler.stop(error, operations: slice) end end end