Module: Chewy::Type::Import

Extended by:
ActiveSupport::Concern
Included in:
Chewy::Type
Defined in:
lib/chewy/type/import.rb,
lib/chewy/type/import/routine.rb,
lib/chewy/type/import/bulk_builder.rb,
lib/chewy/type/import/bulk_request.rb,
lib/chewy/type/import/journal_builder.rb

Defined Under Namespace

Modules: ClassMethods Classes: BulkBuilder, BulkRequest, JournalBuilder, Routine

Constant Summary collapse

IMPORT_WORKER =
lambda do |type, options, total, ids, index|
  ::Process.setproctitle("chewy [#{type}]: import data (#{index + 1}/#{total})")
  routine = Routine.new(type, **options)
  type.adapter.import(*ids, routine.options) do |action_objects|
    routine.process(**action_objects)
  end
  {errors: routine.errors, import: routine.stats, leftovers: routine.leftovers}
end
LEFTOVERS_WORKER =
lambda do |type, options, total, body, index|
  ::Process.setproctitle("chewy [#{type}]: import leftovers (#{index + 1}/#{total})")
  routine = Routine.new(type, **options)
  routine.perform_bulk(body)
  routine.errors
end