Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
268 views
in Technique[技术] by (71.8m points)

ruby on rails - Collect data from each iteration of qbwc

I am using qbwc gem in order to sync data with Quickbooks desktop.

I have to receive more than 15000 customers which I am receiving in the batches of 500 as follow:

requests = {
  customer_query_rq: {
    xml_attributes: { "requestID": "1", 'iterator': "Start" },
    max_returned: 500
  }
}

I want to collect ids of all customers received from Quickbooks desktop after finishing all batches, but it is giving me the ids of only current batch. Is there a way to store ids in some variable which I can access in each iteration?

def handle_response(response, session, job, _request, _data)
    current_sync_ids = []
    response["customer_ret"].each do |customer|
       data[:name] = customer["name"]
       data[:list_id] = customer["list_id"]
       #processting data

       customer_record = Customers.find_or_initialize_by(list_id: data[:list_id])
       customer_record.update(data)
       current_sync_ids << customer_record.id
    end

    #TODO: Need ids of all 15000 customers arrived from quickbooks for some calculation
    puts current_sync_ids
end
question from:https://stackoverflow.com/questions/65917260/collect-data-from-each-iteration-of-qbwc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...