class SalesforceChunker::PrimaryKeyChunkingQuery

Public Class Methods

new(connection:, object:, operation:, query:, **options) click to toggle source
Calls superclass method SalesforceChunker::Job::new
# File lib/salesforce_chunker/primary_key_chunking_query.rb, line 4
def initialize(connection:, object:, operation:, query:, **options)
  batch_size = options[:batch_size] || 100000

  if options[:headers].nil?
    options[:headers] = {"Sforce-Enable-PKChunking": "true; chunkSize=#{batch_size};" }
  else
    options[:headers].reverse_merge!({"Sforce-Enable-PKChunking": "true; chunkSize=#{batch_size};" })
  end

  super(connection: connection, object: object, operation: operation, **options)
  @log.info "Using Primary Key Chunking"
  @initial_batch_id = create_batch(query)
end

Public Instance Methods

get_batch_statuses() click to toggle source
# File lib/salesforce_chunker/primary_key_chunking_query.rb, line 18
def get_batch_statuses
  batches = super
  finalize_chunking_setup(batches) if @batches_count.nil?
  batches
end

Private Instance Methods

finalize_chunking_setup(batches) click to toggle source
# File lib/salesforce_chunker/primary_key_chunking_query.rb, line 26
def finalize_chunking_setup(batches)
  initial_batch = batches.select { |batch| batch["id"] == @initial_batch_id }.first
  if initial_batch && initial_batch["state"] == "NotProcessed"
    @batches_count = batches.length - 1
    close
  end
end