Speed up geocoding/deal better with slow geocoding.

- set limit=1
 - set timeout=10s
This commit is contained in:
Miles Gould committed 2013-09-05 13:10:47 +01:00
1 parent 67ed1e2170
commit d6972da84f
3 files changed
+9 -1

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ class PlacesController < ApplicationController
end
query = Geocoder::Query.new(
@place, :distance => @distance, :units => @units
@place, :distance => @distance, :units => @units, :params => {limit: 1}
)
location = Geocoder.search(query)
if location && location[0] && location[0].coordinates
+7
View File
@@ -206,6 +206,13 @@ class Member < ActiveRecord::Base
private
def geocode
unless self.location.blank?
self.latitude, self.longitude =
Geocoder.coordinates(location, params: {limit: 1})
end
end
def empty_unwanted_geocodes
if self.location.blank?
self.latitude = nil
+1
View File
@@ -1,5 +1,6 @@
Geocoder.configure(
:units => :km,
:timeout => 10,
:http_headers => {
"User-Agent" =>
"#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}",