Closed tcmal closed 5 years ago
Hi @tcmal,
Thanks for this contribution. I am going to cc @tkwidmer or @mi-wood to review this, since I don't usually deal with the DB. I will say, this seems like a neat premise!
And... Happy Hacktoberfest! :jack_o_lantern: :computer: :sparkles: :fallen_leaf:
Merging into a refuge/ branch so I can fix the test
By the way, when I looked at this, it made the SEEDING_DONT_GEOCODE
thing I did in #513 not work.
I'm not fluent with Ruby enough to get why, although I can tell a lot is changed around in the same file that #513 touched, so it makes sense.
(Not sure how important that is, probably not enough to block this new feature, but if I can help make it work again, would be happy to.)
Context
Generally, this makes the data more consistent, however this relies more on the geocode lookup being correct for what the user puts in. It might be a good idea to force the user to preview (via google maps) before they can submit a restroom, or to use a proper address lookup. Thoughts?
Summary of Changes
Restrooms will now populate the geocode, then set the address fields to the address from a reverse lookup before validation.
The address field must be unique. This is only enforced in the activerecord model & not the database schema, meaning it won't complain about existing records / manually added records.
Added a task that iterates over each restroom and re-populates the address from a reverse geocode lookup (
db:reverse_geocode
/db:reverse_geocode[dry_run]
)