Skip to content
Snippets Groups Projects
Commit 8edcaa3b authored by Alex Reisner's avatar Alex Reisner
Browse files

Issue warning on Google API quota error.

parent 0eb01736
Branches
Tags
No related merge requests found
...@@ -175,10 +175,7 @@ If anyone has a more elegant solution to this problem I am very interested in se ...@@ -175,10 +175,7 @@ If anyone has a more elegant solution to this problem I am very interested in se
== To-do List == To-do List
* handle OVER_QUERY_LIMIT error * support different ORMs (DataMapper, Mongoid, etc)
* raise exception? maybe only when address! or search! is called
* print warning?
* support DataMapper, Mongoid, etc
* use completely separate "drivers" for different AR adapters? * use completely separate "drivers" for different AR adapters?
* seems reasonable since we're using very DB-specific features * seems reasonable since we're using very DB-specific features
* also need to make sure 'mysql2' is supported * also need to make sure 'mysql2' is supported
......
...@@ -49,7 +49,11 @@ module Geocoder ...@@ -49,7 +49,11 @@ module Geocoder
def parsed_response(query, reverse = false) def parsed_response(query, reverse = false)
if doc = fetch_data(query, reverse) if doc = fetch_data(query, reverse)
doc = ActiveSupport::JSON.decode(doc) doc = ActiveSupport::JSON.decode(doc)
doc && doc['status'] == "OK" ? doc : nil if doc && doc['status'] == "OK"
return doc
elsif doc['status'] == "OVER_QUERY_LIMIT"
warn "Google Geocoder API error: quota exceeded."
end
end end
end end
...@@ -78,3 +82,4 @@ module Geocoder ...@@ -78,3 +82,4 @@ module Geocoder
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment