Speed up geocoding/deal better with slow geocoding.

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

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

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

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}",