Browse Source

Add debug logs

master
Gautier P 1 year ago
parent
commit
7790eb0a32
  1. 3
      flatisfy/__main__.py
  2. 2
      flatisfy/data_files/__init__.py
  3. 4
      flatisfy/filters/__init__.py
  4. 14
      flatisfy/filters/metadata.py

3
flatisfy/__main__.py

@ -113,7 +113,8 @@ def main(): @@ -113,7 +113,8 @@ def main():
# Set logger
if args.vv:
logging.getLogger("").setLevel(logging.DEBUG)
logging.getLogger("sqlalchemy.engine").setLevel(logging.DEBUG)
logging.getLogger("titlecase").setLevel(logging.INFO)
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
elif args.verbose:
logging.getLogger("").setLevel(logging.INFO)
# sqlalchemy INFO level is way too loud, just stick with WARNING

2
flatisfy/data_files/__init__.py

@ -174,7 +174,7 @@ def _preprocess_laposte(): @@ -174,7 +174,7 @@ def _preprocess_laposte():
)
)
except KeyError:
LOGGER.info("Missing data for postal code %s, skipping it.", fields["code_postal"])
LOGGER.debug("Missing data for postal code %s, skipping it.", fields["code_postal"])
return postal_codes_data

4
flatisfy/filters/__init__.py

@ -43,7 +43,7 @@ def refine_with_housing_criteria(flats_list, constraint): @@ -43,7 +43,7 @@ def refine_with_housing_criteria(flats_list, constraint):
flat["id"],
", ".join(constraint["postal_codes"]),
)
is_ok[i] = is_ok[i] and False
is_ok[i] = False
# Check insee code
insee_code = flat["flatisfy"].get("insee_code", None)
if insee_code and "insee_codes" in constraint and insee_code not in constraint["insee_codes"]:
@ -53,7 +53,7 @@ def refine_with_housing_criteria(flats_list, constraint): @@ -53,7 +53,7 @@ def refine_with_housing_criteria(flats_list, constraint):
flat["id"],
", ".join(constraint["insee_codes"]),
)
is_ok[i] = is_ok[i] and False
is_ok[i] = False
# Check time_to
for place_name, time in flat["flatisfy"].get("time_to", {}).items():

14
flatisfy/filters/metadata.py

@ -76,10 +76,10 @@ def fuzzy_match(query, choices, limit=3, threshold=75): @@ -76,10 +76,10 @@ def fuzzy_match(query, choices, limit=3, threshold=75):
Example::
>>> match("Paris 14ème", ["Ris", "ris", "Paris 14"], limit=1)
>>> fuzzy_match("Paris 14ème", ["Ris", "ris", "Paris 14"], limit=1)
[("Paris 14", 100)
>>> match( \
>>> fuzzy_match( \
"Saint-Jacques, Denfert-Rochereau (Colonel Rol-Tanguy), " \
"Mouton-Duvernet", \
["saint-jacques", "denfert rochereau", "duvernet", "toto"], \
@ -212,7 +212,7 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000): @@ -212,7 +212,7 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000):
assert postal_code in [x.postal_code for x in opendata["postal_codes"]]
LOGGER.debug(
"Found postal code in location field for flat %s: %s.",
"Found postal code directly in location field for flat %s: %s.",
flat["id"],
postal_code,
)
@ -274,6 +274,14 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000): @@ -274,6 +274,14 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000):
if position:
flat["flatisfy"]["position"] = position
LOGGER.debug(
"found postal_code=%s insee_code=%s position=%s for flat %s (%s).",
postal_code,
insee_code,
position,
flat["id"],
location,
)
return flats_list

Loading…
Cancel
Save