From b19459b97f06105bd2741fa9a7c94b88650f3911 Mon Sep 17 00:00:00 2001 From: Gautier P Date: Fri, 15 Jan 2021 16:09:45 +0100 Subject: [PATCH] Try fallback to address if location is missing --- flatisfy/filters/metadata.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/flatisfy/filters/metadata.py b/flatisfy/filters/metadata.py index a51798b..1b26cd8 100644 --- a/flatisfy/filters/metadata.py +++ b/flatisfy/filters/metadata.py @@ -147,14 +147,19 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000): for flat in flats_list: location = flat.get("location", None) + if not location: + addr = flat.get("address", None) + if addr: + location = addr['full_address'] if not location: # Skip everything if empty location LOGGER.info( ( "No location field for flat %s, skipping postal " - "code lookup." + "code lookup. (%s)" ), - flat["id"] + flat["id"], + flat["address"] ) continue