From 236f0d10617a2498f7d7889d26068c9f81a541fe Mon Sep 17 00:00:00 2001 From: Deeman Date: Tue, 10 Mar 2026 17:21:59 +0100 Subject: [PATCH] fix(markets): map country names, localised dropdown + avg/top score tooltip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Expand dim_countries.sql CASE to cover 22 missing countries (PL, RO, CO, HU, ZA, KE, BR, CZ, QA, NZ, HR, LV, MT, CR, CY, PA, SV, DO, PE, VE, EE, ID) that fell through to bare ISO codes - Add 19 missing entries to COUNTRY_LABELS (i18n.py) + both locale files (EN + DE dir_country_* keys) including IE which was in SQL but not i18n - Localise map tooltips: routes.py injects country_name via get_country_name(), JS uses c.country_name instead of c.country_name_en - Localise dropdown: apply country_name filter to option labels - Show avg + top score in map tooltip with separate color dots and new map_score_avg / map_score_top i18n keys (EN: "Avg. Score" / "Top City", DE: "Ø Score" / "Top-Stadt") Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 4 ++ .../models/foundation/dim_countries.sql | 44 +++++++++++++++++++ web/src/padelnomics/content/routes.py | 6 ++- .../content/templates/markets.html | 12 +++-- web/src/padelnomics/i18n.py | 19 ++++++++ web/src/padelnomics/locales/de.json | 21 +++++++++ web/src/padelnomics/locales/en.json | 21 +++++++++ 7 files changed, 122 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d6ad7..05d8d24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] +### Fixed +- **Map country names** — 22 countries (PL, RO, CO, HU, ZA, KE, BR, CZ, QA, NZ, HR, LV, MT, CR, CY, PA, SV, DO, PE, VE, EE, ID) that appeared as bare ISO codes on the markets map and dropdown now show proper English/German names. Added country names to `dim_countries.sql`, `COUNTRY_LABELS` (i18n.py), and both locale files. Map tooltips and dropdown are now fully localised via `get_country_name()`. +- **Map score tooltip clarity** — tooltip now shows both "Avg. Score" (country average) and "Top City" (highest location score) with separate color dots, making clear the map bubble color represents the country average — not a cap. + ### Added - **Microsoft Clarity integration** — consent-gated heatmaps and session recordings (project ID via `CLARITY_PROJECT_ID` env var). Script only loads when the user has accepted functional cookies; bootstraps immediately on consent without requiring a reload. Privacy policy (EN + DE) updated with Clarity disclosure: data collection, sub-processor, cookies (`_clck`, `_clsk`), and international transfers. - **IndexNow integration** — push-notify Bing, Yandex, Seznam, and Naver when articles are published/unpublished/edited or suppliers are created. Bulk operations batch all URLs into a single request. Skips silently in dev (no key configured). Serves key verification file at `/{key}.txt`. diff --git a/transform/sqlmesh_padelnomics/models/foundation/dim_countries.sql b/transform/sqlmesh_padelnomics/models/foundation/dim_countries.sql index 3f33648..083adae 100644 --- a/transform/sqlmesh_padelnomics/models/foundation/dim_countries.sql +++ b/transform/sqlmesh_padelnomics/models/foundation/dim_countries.sql @@ -148,6 +148,28 @@ SELECT WHEN 'AE' THEN 'UAE' WHEN 'AU' THEN 'Australia' WHEN 'IE' THEN 'Ireland' + WHEN 'PL' THEN 'Poland' + WHEN 'RO' THEN 'Romania' + WHEN 'CO' THEN 'Colombia' + WHEN 'HU' THEN 'Hungary' + WHEN 'ZA' THEN 'South Africa' + WHEN 'KE' THEN 'Kenya' + WHEN 'BR' THEN 'Brazil' + WHEN 'CZ' THEN 'Czech Republic' + WHEN 'QA' THEN 'Qatar' + WHEN 'NZ' THEN 'New Zealand' + WHEN 'HR' THEN 'Croatia' + WHEN 'LV' THEN 'Latvia' + WHEN 'MT' THEN 'Malta' + WHEN 'CR' THEN 'Costa Rica' + WHEN 'CY' THEN 'Cyprus' + WHEN 'PA' THEN 'Panama' + WHEN 'SV' THEN 'El Salvador' + WHEN 'DO' THEN 'Dominican Republic' + WHEN 'PE' THEN 'Peru' + WHEN 'VE' THEN 'Venezuela' + WHEN 'EE' THEN 'Estonia' + WHEN 'ID' THEN 'Indonesia' ELSE ac.country_code END AS country_name_en, LOWER(REGEXP_REPLACE( @@ -172,6 +194,28 @@ SELECT WHEN 'AE' THEN 'UAE' WHEN 'AU' THEN 'Australia' WHEN 'IE' THEN 'Ireland' + WHEN 'PL' THEN 'Poland' + WHEN 'RO' THEN 'Romania' + WHEN 'CO' THEN 'Colombia' + WHEN 'HU' THEN 'Hungary' + WHEN 'ZA' THEN 'South Africa' + WHEN 'KE' THEN 'Kenya' + WHEN 'BR' THEN 'Brazil' + WHEN 'CZ' THEN 'Czech Republic' + WHEN 'QA' THEN 'Qatar' + WHEN 'NZ' THEN 'New Zealand' + WHEN 'HR' THEN 'Croatia' + WHEN 'LV' THEN 'Latvia' + WHEN 'MT' THEN 'Malta' + WHEN 'CR' THEN 'Costa Rica' + WHEN 'CY' THEN 'Cyprus' + WHEN 'PA' THEN 'Panama' + WHEN 'SV' THEN 'El Salvador' + WHEN 'DO' THEN 'Dominican Republic' + WHEN 'PE' THEN 'Peru' + WHEN 'VE' THEN 'Venezuela' + WHEN 'EE' THEN 'Estonia' + WHEN 'ID' THEN 'Indonesia' ELSE ac.country_code END, '[^a-zA-Z0-9]+', '-' )) AS country_slug, diff --git a/web/src/padelnomics/content/routes.py b/web/src/padelnomics/content/routes.py index 80ef604..1c30098 100644 --- a/web/src/padelnomics/content/routes.py +++ b/web/src/padelnomics/content/routes.py @@ -18,7 +18,7 @@ from ..core import ( fetch_all, fetch_one, ) -from ..i18n import get_translations +from ..i18n import get_country_name, get_translations bp = Blueprint( "content", @@ -208,10 +208,14 @@ async def markets(): SELECT country_code, country_name_en, country_slug, city_count, total_venues, avg_market_score, avg_opportunity_score, + top_opportunity_score, lat, lon FROM serving.pseo_country_overview ORDER BY total_venues DESC """) + lang = g.get("lang", "en") + for c in map_countries: + c["country_name"] = get_country_name(c["country_code"], lang) # Sort so user's country renders last (on top in Leaflet z-order) user_country = g.get("user_country", "") if user_country and map_countries: diff --git a/web/src/padelnomics/content/templates/markets.html b/web/src/padelnomics/content/templates/markets.html index f140a02..182d5e8 100644 --- a/web/src/padelnomics/content/templates/markets.html +++ b/web/src/padelnomics/content/templates/markets.html @@ -55,7 +55,7 @@ hx-include="#market-q, #market-region"> {% for c in countries %} - + {% endfor %} @@ -86,7 +86,7 @@