app/views/manage/dashboard/map_data.tsv.erb in hackathon_manager-0.7.1 vs app/views/manage/dashboard/map_data.tsv.erb in hackathon_manager-0.8.0

- old
+ new

@@ -1,18 +1,25 @@ <% cache(cache_key_for_questionnaires) do %> <%= "id\tapps" %> <% counties = {} amount = 1 +redo_count = 0 +redo_limit = 10 @schools.each do |school| if school.fips_code.blank? next if school.city.blank? || school.state.blank? resp = HTTParty.get("https://maps.googleapis.com/maps/api/geocode/json?address=#{CGI.escape(school.city)}+#{CGI.escape(school.state)}&sensor=true") results = resp.parsed_response["results"][0] if results.blank? + if redo_count >= redo_limit + raise 'Exceeded maximum number of retries: No results from Google Maps API.' + end + redo_count += 1 redo end + redo_count = 0 lat = results["geometry"]["location"]["lat"] lng = results["geometry"]["location"]["lng"] next if lat.blank? || lng.blank?