lib/rocket_job/sliced/input.rb
def upload_arel(arel, *column_names, &block)
        create_indexes
        unless block
          column_names = column_names.collect(&:to_sym)
          column_names << :id if column_names.size.zero?

          block =
            if column_names.size == 1
              column = column_names.first
              ->(model) { model.send(column) }
            else
              ->(model) { column_names.collect { |c| model.send(c) } }
            end
          # find_each requires the :id column in the query
          selection = column_names.include?(:id) ? column_names : column_names + [:id]
          arel      = arel.select(selection)
        end

        Writer::Input.collect(self) do |records|
          arel.find_each { |model| records << block.call(model) }
        end
      end
# Upload results from an Arel into RocketJob::SlicedJob.
#
# Params
#   column_names
#     When a block is not supplied, supply the names of the columns to be returned
#     and uploaded into the job
#     These columns are automatically added to the select list to reduce overhead
#
# If a Block is supplied it is passed the model returned from the database and should
# return the work item to be uploaded into the job.
#
# Returns [Integer] the number of records uploaded
#
# Example: Upload id's for all users
#   arel = User.all
#   job.record_count = job.upload_arel(arel)
#
# Example: Upload selected user id's
#   arel = User.where(country_code: 'US')
#   job.record_count = job.upload_arel(arel)
#
# Example: Upload user_name and zip_code
#   arel = User.where(country_code: 'US')
#   job.record_count = job.upload_arel(arel, :user_name, :zip_code)
Upload results from an Arel into RocketJob::SlicedJob.
Params
column_names
When a block is not supplied, supply the names of the columns to be returned
and uploaded into the job
These columns are automatically added to the select list to reduce overhead

If a Block is supplied it is passed the model returned from the database and should
return the work item to be uploaded into the job.

Returns [Integer] the number of records uploaded






Upload results from an Arel into RocketJob :: SlicedJob . Params column_names When a block is not supplied supply the names of the columns to be returned and uploaded into the job These columns are automatically added to the select list to reduce overhead If a Block is supplied it is passed the model returned from the database and should return the work item to be uploaded into the job . Returns [ Integer ] the number of records uploaded
def upload_arel(arel, *column_names, &block)
        create_indexes
        unless block
          column_names = column_names.collect(&:to_sym)
          column_names << :id if column_names.size.zero?
          block =
            if column_names.size == 1
              column = column_names.first
              ->(model) { model.send(column) }
            else
              ->(model) { column_names.collect { |c| model.send(c) } }
            end
          selection = column_names.include?(:id) ? column_names : column_names + [:id]
          arel      = arel.select(selection)
        end
        Writer::Input.collect(self) do |records|
          arel.find_each { |model| records << block.call(model) }
        end
      end
def upload_arel ( arel , * column_names , & block ) create_indexes unless block column_names = column_names . collect ( & :to_sym ) column_names << :id if column_names . size . zero? block = if column_names . size == 1 column = column_names . first -> ( model ) { model . send ( column ) } else -> ( model ) { column_names . collect { | c | model . send ( c ) } } end selection = column_names . include? ( :id ) ? column_names : column_names + [ :id ] arel = arel . select ( selection ) end Writer :: Input . collect ( self ) do | records | arel . find_each { | model | records << block . call ( model ) } end end
Upload results from an Arel into RocketJob::SlicedJob.
Upload results from an Arel into RocketJob :: SlicedJob .
# find_each requires the :id column in the query
arel
column_names
block