fix: correct artist birth/formation location display order

Two bugs in location_discovery.rs:
- Display format was "Country, City" instead of "City, Country"
- Country was derived from area (where artist is active) instead
  of country code (where artist was born/formed)

Hans Zimmer now shows "Frankfurt am Main, Germany" instead of
"United States, Frankfurt am Main"

Closes #235

cc
This commit is contained in:
vicrodh committed 2026-03-31 16:54:07 -06:00
1 parent d19c142d4f
commit f702622e0e
1 file changed
+13 -50
+13 -50
View File
@@ -57,57 +57,20 @@ fn resolve_location(
.map(|t| t.eq_ignore_ascii_case("subdivision"))
.unwrap_or(false);
let country_name = area
.and_then(|a| {
if a.area_type
.as_deref()
.map(|t| t.eq_ignore_ascii_case("country"))
.unwrap_or(false)
{
Some(a.name.clone())
} else {
None
}
})
.or_else(|| country.map(|c| country_code_to_name(c)));
// For birth/formation location, derive country from the country code
// (not from area, which represents where the artist is currently active)
let country_name = country.map(|c| country_code_to_name(c));
if is_city {
let display = if let Some(ref cn) = country_name {
format!("{}, {}", cn, ba.name)
} else {
ba.name.clone()
};
let precision = if is_city {
LocationPrecision::City
} else if is_subdivision {
LocationPrecision::State
} else {
LocationPrecision::City // best guess
};
return Some(ArtistLocation {
city: Some(ba.name.clone()),
area_id: Some(ba.id.clone()),
country: country_name,
country_code: cc,
display_name: display,
precision: LocationPrecision::City,
});
}
if is_subdivision {
let display = if let Some(ref cn) = country_name {
format!("{}, {}", cn, ba.name)
} else {
ba.name.clone()
};
return Some(ArtistLocation {
city: Some(ba.name.clone()),
area_id: Some(ba.id.clone()),
country: country_name,
country_code: cc,
display_name: display,
precision: LocationPrecision::State,
});
}
// begin_area exists but type unknown — still use it as best guess
let display = if let Some(ref cn) = country_name {
format!("{}, {}", cn, ba.name)
format!("{}, {}", ba.name, cn)
} else {
ba.name.clone()
};
@@ -118,7 +81,7 @@ fn resolve_location(
country: country_name,
country_code: cc,
display_name: display,
precision: LocationPrecision::City,
precision,
});
}
@@ -144,7 +107,7 @@ fn resolve_location(
// Non-country area (could be city without begin_area)
let country_name = country.map(|c| country_code_to_name(c));
let display = if let Some(ref cn) = country_name {
format!("{}, {}", cn, a.name)
format!("{}, {}", a.name, cn)
} else {
a.name.clone()
};