alexknowshtml / We-Work-In-Philly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

geocode_or_return is inefficient and probably not needed

bglick opened this issue · comments

In reviewing the code to generate the maps json, I noticed that both the Companies & Groups call geocode_or_return and only load the json if this method returns true.

geocode_or_return calls the external Geocoder api for every address that doesn't have a latitude and longitude already set. Since the Company class already sets the location in the after_validation callback, making the separate API call within the context of an interactive request seems excessive. There's a very low chance that an address would have a positive if it didn't have one when it was most recently saved.