From 105b0b2a51edd2124ca1df2c689935daffbc1e94 Mon Sep 17 00:00:00 2001 From: louispaulb Date: Mon, 1 Jun 2026 22:40:47 -0400 Subject: [PATCH] =?UTF-8?q?feat(ops):=20per-address=20competitor=20column?= =?UTF-8?q?=20via=20Qu=C3=A9bec=20IHV=20open=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the reCAPTCHA-blocked Cogeco scraper with the authoritative Québec "Accès Internet haute vitesse" open ArcGIS data (providers declared to the gov by the providers themselves — validated to match Cogeco's own popup). - hub lib/serviceability.js: address → ADR (Adresse_complete → IdAdresse + Etat_hiv, civic+postal match w/ JS street disambiguation) → FRN table (IdAdresse → FRN_nom providers + signup URLs). Referer-gated proxy, disk cache (90d), polite rate limit. Routes /serviceability/lookup[-batch]. - ops ReportInternetCherPage: "Concurrence (FSI)" column — provider chips (Cogeco highlighted), batch-fetched on demand with progress; "Cogeco disponible" summary card = churn-risk count; manual Cogeco verify icon kept. Validated live: 37 Chemin Noël → Cogeco+Targo, 147 Montée Richard → Targo only, Repentigny → Bell+Cogeco. Endpoints documented in memory/reference_quebec_ihv.md. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/ops/src/api/reports.js | 15 ++ apps/ops/src/pages/ReportInternetCherPage.vue | 89 ++++++- services/targo-hub/lib/serviceability.js | 244 ++++++++++++++++++ services/targo-hub/server.js | 2 + 4 files changed, 342 insertions(+), 8 deletions(-) create mode 100644 services/targo-hub/lib/serviceability.js diff --git a/apps/ops/src/api/reports.js b/apps/ops/src/api/reports.js index c551e93..82ee17c 100644 --- a/apps/ops/src/api/reports.js +++ b/apps/ops/src/api/reports.js @@ -10,6 +10,21 @@ async function hubFetch (path) { return res.json() } +/** + * Per-address provider lookup (Québec IHV open data) for a batch of addresses. + * @param {Array<{key,address1,city,zip}>} items (max 80 per call) + * @returns {Promise<{results: Record}>} + */ +export async function lookupServiceabilityBatch (items) { + const res = await fetch(HUB + '/serviceability/lookup-batch', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ items }), + }) + if (!res.ok) throw new Error('Serviceability API error: ' + res.status) + return res.json() +} + /** * Revenue report — GL entries grouped by Income account and month * @param {string} start YYYY-MM-DD diff --git a/apps/ops/src/pages/ReportInternetCherPage.vue b/apps/ops/src/pages/ReportInternetCherPage.vue index b038ca4..98978be 100644 --- a/apps/ops/src/pages/ReportInternetCherPage.vue +++ b/apps/ops/src/pages/ReportInternetCherPage.vue @@ -4,6 +4,11 @@
Clients qui paient cher — Internet
+ + Vérifie, pour chaque adresse, les fournisseurs Internet disponibles (données ouvertes Québec IHV). Cogeco surligné = alternative existante = risque de churn. + @@ -69,6 +74,13 @@
{{ formatMoney(totalDiscounts) }}
+
+
+
Cogeco disponible
+
{{ cogecoCount }}
+
{{ svcBusy ? `vérifié ${svcProgress.done}/${svcProgress.total}` : 'risque de churn' }}
+
+
@@ -145,12 +157,29 @@ -