5 # Toy variable to limit the number of pages so that we can test a bit
11 restaurants.concat(go.fetch_page(i+=1)) until go.pages != nil && (i >= go.pages || i >= max_pages)
13 puts "Finished fetching, now importing"
14 # NOTE: I had to move this require to after parsing is done, otherwise it was breaking the
15 # results of the regular expressoins, particularly trying to extract the address. Don't ask me why
16 require '../dondeback/config/environment'
18 restaurants.each do |restaurant|
19 v = Venue.find_by_name(restaurant['name'])
20 if !v.nil? and v.address == restaurant['address'] then
21 puts "Skipping = [" + v.name + "]"
23 Venue.create(restaurant)
27 puts "Done importing, now geocoding"
30 # Find all venues that lack coordinates and geocode each of them individually
31 # TODO Look for alternative geocoders, hopefully supporting batch geocoding
32 venues = Venue.find(:all,:conditions => ["lat is null"])
33 puts "There are " + venues.length.to_s + " unmapped venues"
34 venues.each {|v| Geocode.map_venue v}