mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-16 04:52:29 -04:00
Speed up geocoding/deal better with slow geocoding.
- set limit=1 - set timeout=10s
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,5 +1,6 @@
|
||||
Geocoder.configure(
|
||||
:units => :km,
|
||||
:timeout => 10,
|
||||
:http_headers => {
|
||||
"User-Agent" =>
|
||||
"#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}",
|
||||
|
||||
Reference in New Issue
Block a user