Browse Source

Add debug logs

Gautier P 10 months ago
parent
commit
7790eb0a32

+ 2
- 1
flatisfy/__main__.py View File

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

+ 1
- 1
flatisfy/data_files/__init__.py View File

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

+ 2
- 2
flatisfy/filters/__init__.py View File

@@ -43,7 +43,7 @@ def refine_with_housing_criteria(flats_list, constraint):
43 43
                 flat["id"],
44 44
                 ", ".join(constraint["postal_codes"]),
45 45
             )
46
-            is_ok[i] = is_ok[i] and False
46
+            is_ok[i] = False
47 47
         # Check insee code
48 48
         insee_code = flat["flatisfy"].get("insee_code", None)
49 49
         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 53
                 flat["id"],
54 54
                 ", ".join(constraint["insee_codes"]),
55 55
             )
56
-            is_ok[i] = is_ok[i] and False
56
+            is_ok[i] = False
57 57
 
58 58
         # Check time_to
59 59
         for place_name, time in flat["flatisfy"].get("time_to", {}).items():

+ 11
- 3
flatisfy/filters/metadata.py View File

@@ -76,10 +76,10 @@ def fuzzy_match(query, choices, limit=3, threshold=75):
76 76
 
77 77
     Example::
78 78
 
79
-        >>> match("Paris 14ème", ["Ris", "ris", "Paris 14"], limit=1)
79
+        >>> fuzzy_match("Paris 14ème", ["Ris", "ris", "Paris 14"], limit=1)
80 80
         [("Paris 14", 100)
81 81
 
82
-        >>> match( \
82
+        >>> fuzzy_match( \
83 83
                 "Saint-Jacques, Denfert-Rochereau (Colonel Rol-Tanguy), " \
84 84
                 "Mouton-Duvernet", \
85 85
                 ["saint-jacques", "denfert rochereau", "duvernet", "toto"], \
@@ -212,7 +212,7 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000):
212 212
             assert postal_code in [x.postal_code for x in opendata["postal_codes"]]
213 213
 
214 214
             LOGGER.debug(
215
-                "Found postal code in location field for flat %s: %s.",
215
+                "Found postal code directly in location field for flat %s: %s.",
216 216
                 flat["id"],
217 217
                 postal_code,
218 218
             )
@@ -274,6 +274,14 @@ def guess_postal_code(flats_list, constraint, config, distance_threshold=20000):
274 274
 
275 275
         if position:
276 276
             flat["flatisfy"]["position"] = position
277
+        LOGGER.debug(
278
+            "found postal_code=%s insee_code=%s position=%s for flat %s (%s).",
279
+            postal_code,
280
+            insee_code,
281
+            position,
282
+            flat["id"],
283
+            location,
284
+        )
277 285
 
278 286
     return flats_list
279 287