lib/eco/api/session/batch.rb in eco-helpers-0.8.3 vs lib/eco/api/session/batch.rb in eco-helpers-0.8.4
- old
+ new
@@ -48,11 +48,11 @@
status.type = :search
entries = status.queue
puts "\n"
entries.each_with_index do |entry, i|
- if (i % 500 == 0)
+ if (i % 10 == 0)
percent = i * 100 / entries.length
print "Searching: #{percent.round}% (#{i}/#{entries.length} entries)\r"
$stdout.flush
end
@@ -105,17 +105,18 @@
params.merge!(results_from: results_from) unless !results_from
people_res, response = client_get(client, params: params.merge(page: page), silent: silent)
people += people_res
total_iterations ||= response.body["total_pages"]
- no_pages = !response.body["total_pages"]
+ no_pages = !response.body["total_pages"]
total_results ||= response.body["total_results"]
if !total_iterations
total_iterations ||= (total_results.to_f / params[:per_page]).ceil
end
msg = "iteration number: #{page}/#{total_iterations}, got num people #{people_res.length}, with total #{people.length} people got"
+ msg = "search(q=#{params[:q]}) " + msg if params.key?(:q)
logger.info(msg) unless silent
iterate = (no_pages && results_from = response.body["next_results_from"]) || (looping && page < total_iterations)
break unless iterate
page += 1