Grab secondary types as well
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 1m43s
Cargo CI / Lint (pull_request) Failing after 1m5s

This commit is contained in:
Wojciech Kozlowski 2024-08-26 16:24:03 +02:00
parent 0fe8504b8c
commit 43dbed7f8b

View File

@ -150,6 +150,7 @@ struct SearchReleaseGroup {
title: String,
first_release_date: String,
primary_type: SerdeAlbumPrimaryType,
secondary_types: Option<Vec<SerdeAlbumSecondaryType>>,
}
impl TryFrom<SearchReleaseGroup> for Match<Album> {
@ -160,7 +161,10 @@ impl TryFrom<SearchReleaseGroup> for Match<Album> {
entity.title,
AlbumDate::from_mb_date(&entity.first_release_date)?,
Some(entity.primary_type.into()),
vec![],
entity
.secondary_types
.map(|v| v.into_iter().map(|st| st.into()).collect())
.unwrap_or_default(),
);
let mbref = MbAlbumRef::from_uuid_str(entity.id)
.map_err(|err| Error::MbidParse(err.to_string()))?;
@ -229,7 +233,7 @@ pub enum SerdeAlbumSecondaryTypeDef {
FieldRecording,
}
#[derive(Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize)]
pub struct SerdeAlbumSecondaryType(
#[serde(with = "SerdeAlbumSecondaryTypeDef")] AlbumSecondaryType,
);
@ -320,6 +324,7 @@ mod tests {
title: String::from("an album"),
first_release_date: String::from("1986-04"),
primary_type: SerdeAlbumPrimaryType(AlbumPrimaryType::Album),
secondary_types: Some(vec![SerdeAlbumSecondaryType(AlbumSecondaryType::Live)]),
};
let response = ResponseSearchReleaseGroup {
release_groups: vec![release_group],
@ -350,7 +355,7 @@ mod tests {
AlbumId::new("an album"),
(1986, 4),
Some(AlbumPrimaryType::Album),
vec![],
vec![AlbumSecondaryType::Live],
);
album.set_musicbrainz_ref(
MbAlbumRef::from_uuid_str("11111111-1111-1111-1111-111111111111").unwrap(),