0

I want to populate my database with 300 users and products, but the process is too fast, and so are the requests to Google API. How can I slow it down ? (1 request every second max). I tried that in the config/environments/development.rb but it didn't worked :

Geocoder.configure(timeout: 10000)

Here is what Geocoder renders :

Geocoding API not responding fast enough (use Geocoder.configure(:timeout => ...) to set limit).
Flo Rahl
  • 1,044
  • 1
  • 16
  • 33

1 Answers1

0

I think setting the timeout config on Geocoder will only let Geocoder wait longer for an external API response, it won't help you populating the db at a slower pace. And I believe that's what you want as external APIs may not be able to answer a huge amount of simultaneous calls from your app.

You may need to try something like this

 Product.populate 300 do |product|
   sleep 0.2
   ...
 end
NicoArbogast
  • 423
  • 2
  • 4