Try fallback to address if location is missing

This commit is contained in:
Gautier P 2021-01-15 16:09:45 +01:00
parent 0da04a4b6e
commit b19459b97f
1 changed files with 7 additions and 2 deletions

View File

@ -147,14 +147,19 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000):
for flat in flats_list: for flat in flats_list:
location = flat.get("location", None) location = flat.get("location", None)
if not location:
addr = flat.get("address", None)
if addr:
location = addr['full_address']
if not location: if not location:
# Skip everything if empty location # Skip everything if empty location
LOGGER.info( LOGGER.info(
( (
"No location field for flat %s, skipping postal " "No location field for flat %s, skipping postal "
"code lookup." "code lookup. (%s)"
), ),
flat["id"] flat["id"],
flat["address"]
) )
continue continue