batch-loader icon indicating copy to clipboard operation
batch-loader copied to clipboard

How to debug the code inside batch loader block

Open xchen1189 opened this issue 3 years ago • 1 comments

Hey all, I'm trying to print out the variable values inside of batch blocks for debug purpose, but somehow it doesn't work. Nothing print out. I wonder if anyone knows how to do that? Thanks a lot.

BatchLoader.for(object).batch do |meals, loader|
  billables = InternalClient::MakomoClient.billables_by_consumption_owners(
     owners: meals,
     internal_name: MENU_PRICE_NAME
  ).group_by { |b| b.owner_id.to_i }

  puts billables

  meals.each do |meal|
    menu_price = billables[meal.id].result.first.amount
    loader.call(meal, menu_price)
  end
end

xchen1189 avatar Jun 23 '21 20:06 xchen1189

Given the nature of BatchLoader doing something like this will help you:

$stdout.write "I want do debug this"

elcuervo avatar Nov 18 '21 21:11 elcuervo