Closed DeeDeeG closed 4 years ago
To verify this is happening, query the "latest restrooms" API endpoint. Inspect latitude
and longitude
fields to see they are set as null
.
^ click to expand.
I believe we are over our query limit for the Maps API. This is the full output of what happens in testing when I submit a new restroom:
web_1 | Started POST "/restrooms" for 172.18.0.1 at 2018-10-11 18:40:52 +0000
web_1 | Processing by RestroomsController#create as HTML
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"qPZcmZwkgPT7gkp1HWwz0XGnDR7PCyFTi3sG0ck54doh9WWuBu3U07MDU9Aw6Ef/cxLsEcF9mIWfyUppzhWdxA==", "restroom"=>{"name"=>"a", "street"=>"a", "city"=>"a", "state"=>"a", "country"=>"US", "latitude"=>"", "longitude"=>"", "accessible"=>"false", "unisex"=>"false", "changing_table"=>"false", "directions"=>"hi", "comment"=>"hello"}, "commit"=>"Save Restroom"}
web_1 | (0.2ms) BEGIN
web_1 | ↳ app/controllers/restrooms_controller.rb:31
web_1 | Google Geocoding API error: over query limit.
web_1 | Restroom Create (0.8ms) INSERT INTO "restrooms" ("name", "street", "city", "state", "directions", "comment", "created_at", "updated_at", "country") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id" [["name", "a"], ["street", "a"], ["city", "a"], ["state", "a"], ["directions", "hi"], ["comment", "hello"], ["created_at", "2018-10-11 18:40:52.810075"], ["updated_at", "2018-10-11 18:40:52.810075"], ["country", "US"]]
web_1 | ↳ app/controllers/restrooms_controller.rb:31
web_1 | (26.2ms) COMMIT
web_1 | ↳ app/controllers/restrooms_controller.rb:31
web_1 | [i18n-debug] en.restroom.flash.new => "A new restroom entry has been created for %{name}."
web_1 | Redirected to http://127.0.0.1:3000/restrooms/22
web_1 | Completed 302 Found in 439ms (ActiveRecord: 27.3ms)
particularly of note is this line:
web_1 | Google Geocoding API error: over query limit.
And that the new restroom entry page sent "latitude"=>"", "longitude"=>""
to our API when POST
ing the new entry to [in this case the testing version of] our db.
Here's a FAQ entry for addressing this issue, over at the Maps API documentation.
How do I resolve the error codes:
OVER_DAILY_LIMIT
orOVER_QUERY_LIMIT
? https://developers.google.com/maps/faq#over-limit-key-error
Extra Credit: We might spend some time ensuring how we use our API key matches these guidelines:
https://developers.google.com/maps/documentation/geocoding/web-service-best-practices
https://developers.google.com/maps/api-key-best-practices
(As usual with Maps API documentation, there's at least two pages for almost identical subjects, and it's not always clear which one pertains to our particular usage... But hopefully either of these guides is relevant, and hopefully they aren't contradictory...)
Edit: I think it's the "API key best practices" one.
Reopening because I still have to fix all the old entries
Just documenting that we had another extended geocoding outage that lasted until 2020-04-11T18:04:55.252Z
in API/server time.
The outage appears to have started at 2019-11-11T12:08:53.407Z
API/server time.
This represents roughly 1790
entries, (that is, roughly 179 pages of 10 entries each), though some are duplicates, and some of these were successfully geocoded, perhaps via the "guess my location" client-side button.
Was able to fix these:
Restroom.where(latitude: nil).each do |r|
r.save
end
Down to 24 with nil lat. Looks like they're mostly spam that go through somehow. I'll look later and maybe delete them.
Context
See:
Summary
Lots of our restroom entries these days have
latitude: null
andlongitude: null
.(Any use-case of the app focused on a map view, or search-by-location, will highlight this problem. Since those are mostly how the mobile apps are used, this issue is most apparent to users of the mobile app. However, this affects the core database itself, so the web app and both mobile apps are likely just seeing the same issue; We're receiving entries with no actual geo-location data.)
Suggested Solution for Backlog
latitude
andlongitude
, submit updated entry to database.Solution to Prevent more Entries with Null Geolocation Data