Sha256: 215aa169d9bd9b7107da0a78d4cbb5bf2da7ddcee36b0f618bc4bd349cf73be5

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

module Workarea
  module FlowIo
    # Reads the CSV stored in a `Workarea::FlowIo::Import`, and
    # processes each row with `FlatFileItem.import`
    class ProcessImport
      include Sidekiq::Worker
      include Sidekiq::CallbacksWorker

      sidekiq_options \
        lock: :until_executing,
        enqueue_on: { Import => [:create] }

      def perform(id)
        import = Import.find(id)

        import.update!(started_at: Time.current)

        experiences = FlowIo.client.experiences.get(FlowIo.organization_id)

        CSV.foreach(import.file_path, headers: true) do |row|
          ImportedItem.process(row, experiences)
        end

        import.update!(completed_at: Time.current)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-flow_io-1.2.1 app/workers/workarea/flow_io/process_import.rb