Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store reverse geo-coded address & force unique addresses #518

Merged
merged 6 commits into from
Nov 18, 2018
Merged

Store reverse geo-coded address & force unique addresses #518

merged 6 commits into from
Nov 18, 2018

Conversation

tcmal
Copy link

@tcmal tcmal commented Oct 14, 2018

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])

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 14, 2018

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! 🎃 💻 ✨ 🍂

@DeeDeeG DeeDeeG added enhancement Ready for Review Hacktoberfest These are issues or pull requests related to Hacktoberfest (https://hacktoberfest.digitalocean.com/) labels Oct 14, 2018

puts ""

Restroom.all.each do |restroom|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do this for all Restrooms, or can we just do ones that have some columns missing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends if you're particularly fussy about the display, for example casing and Street vs St.

lib/tasks/reverse_geocode.rake Outdated Show resolved Hide resolved
app/models/restroom.rb Outdated Show resolved Hide resolved
@mi-wood mi-wood changed the base branch from develop to 399-duplicates November 18, 2018 17:25
@mi-wood
Copy link
Member

mi-wood commented Nov 18, 2018

Merging into a refuge/ branch so I can fix the test

@mi-wood mi-wood merged commit 708a75f into RefugeRestrooms:399-duplicates Nov 18, 2018
@DeeDeeG
Copy link
Contributor

DeeDeeG commented Nov 18, 2018

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Hacktoberfest These are issues or pull requests related to Hacktoberfest (https://hacktoberfest.digitalocean.com/)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants