Commit
[ka2] fix connecteur beaudoin: échouer franchement sur erreur transitoire (page 1 / taxonomie ville) au lieu d'un faux succès à 0 annonce
modified
louka/connectors/beaudoin.py
+8 −1
@@ -104,6 +104,11 @@ class BeaudoinConnector(BaseConnector): | |||
| 104 | statuses = self._terms("property_status") | 104 | statuses = self._terms("property_status") |
| 105 | cities = self._terms("property_city") | 105 | cities = self._terms("property_city") |
| 106 | features = self._terms("property_feature") | 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 | props: list[dict] = [] | 113 | props: list[dict] = [] |
| 109 | for page in range(1, self.max_pages + 1): | 114 | for page in range(1, self.max_pages + 1): |
@@ -111,7 +116,9 @@ class BeaudoinConnector(BaseConnector): | |||
| 111 | batch = self.get( | 116 | batch = self.get( |
| 112 | f"{API}/properties?per_page=100&page={page}").json() | 117 | f"{API}/properties?per_page=100&page={page}").json() |
| 113 | except Exception: | 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 | if not isinstance(batch, list) or not batch: | 122 | if not isinstance(batch, list) or not batch: |
| 116 | break | 123 | break |
| 117 | props.extend(batch) | 124 | props.extend(batch) |
| 118 | 125 | ||