alexknowshtml / We-Work-In-Philly

8 stars 14 forks source link

geocode_or_return is inefficient and probably not needed #59

Open bglick opened 11 years ago

bglick commented 11 years ago

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.