Permalink
Browse files

Rake Task: Geocode objects without coordinates with a limit

  • Loading branch information...
1 parent df0ee95 commit 4850f893227dfea6452ef53e1849f704407bd6ff @willywg committed Sep 8, 2011
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/tasks/geocoder.rake
View
@@ -12,4 +12,16 @@ namespace :geocode do
obj.geocode; obj.save
end
end
+
+ desc "Geocode objects without coordinates with a limit."
+ task :with_limit => :environment do
+ limit = ENV['LIMIT'] || ENV['limit']
+ raise "Please specify a LIMIT" unless limit
+
+ klass.not_geocoded.limit(limit).each do |obj|
+ puts "Processing #{obj.class.name} ID##{obj.id}"
+ obj.geocode; obj.save
+ end
+ end
+
end

0 comments on commit 4850f89

Please sign in to comment.