From 4daa707f3e727d780f88e42c8091faf731dbb8c4 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 29 Nov 2025 12:30:15 +0100 Subject: [PATCH] Normalize country code to UK instead of GB - CountriesTool: use 'uk' key for United Kingdom - EGFRatingsHandler: keep UK as-is (no conversion to GB) - Pairable: convert GB to UK (inverse of previous behavior) --- .../src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt | 4 ++-- .../kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt | 3 --- .../main/kotlin/org/jeudego/pairgoth/view/CountriesTool.kt | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt index 94676be..6a628c1 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt @@ -107,9 +107,9 @@ fun Player.Companion.fromJson(json: Json.Object, default: Player? = null) = Play rating = json.getInt("rating") ?: default?.rating ?: badRequest("missing rating"), rank = json.getInt("rank") ?: default?.rank ?: badRequest("missing rank"), country = ( json.getString("country") ?: default?.country ?: badRequest("missing country") ).let { - // EGC uses UK, while FFG and browser language use GB + // normalize to UK (EGF uses UK, ISO uses GB) val up = it.uppercase(Locale.ROOT) - if (up == "UK") "GB" else up + if (up == "GB") "UK" else up }, club = json.getString("club") ?: default?.club ?: badRequest("missing club"), final = json.getBoolean("final") ?: default?.final ?: true, diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt index fafb97b..d426ad2 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt @@ -36,9 +36,6 @@ object EGFRatingsHandler: RatingsHandler(RatingsManager.Ratings.EGF) { if (adjusted < 0) "${-(adjusted - 99) / 100}k" else "${(adjusted + 100) / 100}d" } - if ("UK" == player.getString("country")) { - player["country"] = "GB" - } // fix for missing firstnames if (player.getString("firstname") == null) { player["firstname"] = "" diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/CountriesTool.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/CountriesTool.kt index 97314f3..acbd4f9 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/CountriesTool.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/CountriesTool.kt @@ -95,7 +95,7 @@ class CountriesTool { "fj" to "Fiji", "fr" to "France", "ga" to "Gabon", - "gb" to "United Kingdom", + "uk" to "United Kingdom", "gd" to "Grenada", "ge" to "Georgia", "gg" to "Guernsey",