-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Refactor Venue::Geocoder #471
Conversation
|
||
def map_geo_to_venue | ||
VENUE_GEO_FIELD_MAP.each do |venue_field, geo_field| | ||
next if venue[venue_field].present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deviates from the original implementation, in that we used to write lat
and lng
even when values were present on the venue. I think this is required for the "force geocoding" feature to work correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch. This requirement should be captured in a unit test. I'll go ahead and add one. While we're discussing requirements, why not overwrite every field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're not overwriting all the fields because there are situations where local users will have a better idea how an address should be written than the geocoder will.
Also IIRC, not all of the geocoding backends actually return all the address fields (and this is especially true for international addresses). We probably want to ensure that the address component from geocoder result isn't blank before trying to set it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that. I'll write a unit test to force the original behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, old behavior is restored, and I added another unit test to codify the requirement of not stomping on existing values with blank ones from the geocoder.
🌍 |
Split up complex
#geocode
method into a composed method.