lib/tasks/geocoder.rake in geocoder-1.1.9 vs lib/tasks/geocoder.rake in geocoder-1.2.0
- old
+ new
@@ -1,13 +1,15 @@
namespace :geocode do
desc "Geocode all objects without coordinates."
task :all => :environment do
class_name = ENV['CLASS'] || ENV['class']
sleep_timer = ENV['SLEEP'] || ENV['sleep']
+ batch = ENV['BATCH'] || ENV['batch']
raise "Please specify a CLASS (model)" unless class_name
klass = class_from_string(class_name)
+ batch = batch.to_i unless batch.nil?
- klass.not_geocoded.each do |obj|
+ klass.not_geocoded.find_each(batch_size: batch) do |obj|
obj.geocode; obj.save
sleep(sleep_timer.to_f) unless sleep_timer.nil?
end
end
end