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)
This commit is contained in:
Claude Brisson
2025-11-29 12:30:15 +01:00
parent cbadb4d6bb
commit 4daa707f3e
3 changed files with 3 additions and 6 deletions

View File

@@ -107,9 +107,9 @@ fun Player.Companion.fromJson(json: Json.Object, default: Player? = null) = Play
rating = json.getInt("rating") ?: default?.rating ?: badRequest("missing rating"), rating = json.getInt("rating") ?: default?.rating ?: badRequest("missing rating"),
rank = json.getInt("rank") ?: default?.rank ?: badRequest("missing rank"), rank = json.getInt("rank") ?: default?.rank ?: badRequest("missing rank"),
country = ( json.getString("country") ?: default?.country ?: badRequest("missing country") ).let { 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) 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"), club = json.getString("club") ?: default?.club ?: badRequest("missing club"),
final = json.getBoolean("final") ?: default?.final ?: true, final = json.getBoolean("final") ?: default?.final ?: true,

View File

@@ -36,9 +36,6 @@ object EGFRatingsHandler: RatingsHandler(RatingsManager.Ratings.EGF) {
if (adjusted < 0) "${-(adjusted - 99) / 100}k" if (adjusted < 0) "${-(adjusted - 99) / 100}k"
else "${(adjusted + 100) / 100}d" else "${(adjusted + 100) / 100}d"
} }
if ("UK" == player.getString("country")) {
player["country"] = "GB"
}
// fix for missing firstnames // fix for missing firstnames
if (player.getString("firstname") == null) { if (player.getString("firstname") == null) {
player["firstname"] = "" player["firstname"] = ""

View File

@@ -95,7 +95,7 @@ class CountriesTool {
"fj" to "Fiji", "fj" to "Fiji",
"fr" to "France", "fr" to "France",
"ga" to "Gabon", "ga" to "Gabon",
"gb" to "United Kingdom", "uk" to "United Kingdom",
"gd" to "Grenada", "gd" to "Grenada",
"ge" to "Georgia", "ge" to "Georgia",
"gg" to "Guernsey", "gg" to "Guernsey",