Skip to content

Commit

Permalink
#216 always try refresh lat/lon via geocoding on Resource update
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Oct 27, 2018
1 parent 89be8fb commit 3bba4c4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions GeoHealthCheck/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,14 @@ def update(resource_identifier):
setattr(resource, key, resource_identifier_dict[key])
update_counter += 1

# Update geo-IP if it failed earlier, e.g. during creation
if resource.latitude == 0.0:
resource.latitude, resource.longitude = geocode(resource.url)
if resource.latitude != 0.0:
update_counter += 1
# Always update geo-IP: maybe failure on creation or
# IP-address of URL may have changed.
latitude, longitude = geocode(resource.url)
if latitude != 0.0 and longitude != 0.0:
# Only update for valid lat/lon
resource.latitude = latitude
resource.longitude = longitude
update_counter += 1

except Exception as err:
LOGGER.error("Cannot update resource: %s", err, exc_info=err)
Expand Down

0 comments on commit 3bba4c4

Please sign in to comment.