[ka2] fix connecteur beaudoin: échouer franchement sur erreur transitoire (page 1 / taxonomie ville) au lieu d'un faux succès à 0 annonce
1 changed file +8 −1
modified
louka/connectors/beaudoin.py
+8 −1
@@ -104,6 +104,11 @@ class BeaudoinConnector(BaseConnector): | ||
| 104 | 104 | statuses = self._terms("property_status") |
| 105 | 105 | cities = self._terms("property_city") |
| 106 | 106 | features = self._terms("property_feature") |
| 107 | + # Sans la taxonomie ville, le filtre Grand Montréal rejette tout : | |
| 108 | + # mieux vaut échouer franchement qu'un « succès » à 0 annonce. | |
| 109 | + if not cities: | |
| 110 | + raise RuntimeError( | |
| 111 | + "taxonomie property_city vide/inaccessible — filtre ville impossible") | |
| 107 | 112 | |
| 108 | 113 | props: list[dict] = [] |
| 109 | 114 | for page in range(1, self.max_pages + 1): |
@@ -111,7 +116,9 @@ class BeaudoinConnector(BaseConnector): | ||
| 111 | 116 | batch = self.get( |
| 112 | 117 | f"{API}/properties?per_page=100&page={page}").json() |
| 113 | 118 | except Exception: |
| 114 | − break | |
| 119 | + if page == 1: | |
| 120 | + raise # erreur transitoire ≠ liste vide (évite les faux 0) | |
| 121 | + break # fin de pagination (WP renvoie 400 au-delà) | |
| 115 | 122 | if not isinstance(batch, list) or not batch: |
| 116 | 123 | break |
| 117 | 124 | props.extend(batch) |
| 118 | 125 | |