Compare commits

...

2 Commits

Author SHA1 Message Date
3fb7d719d1 Nits
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 2m0s
Cargo CI / Lint (pull_request) Successful in 1m7s
2024-09-22 16:23:00 +02:00
7c381bece0 fix 2024-09-22 16:16:23 +02:00
4 changed files with 20 additions and 20 deletions

View File

@ -75,7 +75,7 @@ impl<'a> LookupArtistRequest<'a> {
pub struct LookupArtistResponse {
pub id: Mbid,
pub name: ArtistId,
pub sort: Option<ArtistId>,
pub sort_name: ArtistId,
pub disambiguation: Option<String>,
pub release_groups: Vec<LookupArtistResponseReleaseGroup>,
}
@ -92,13 +92,10 @@ struct DeserializeLookupArtistResponse {
impl From<DeserializeLookupArtistResponse> for LookupArtistResponse {
fn from(value: DeserializeLookupArtistResponse) -> Self {
let sort: Option<ArtistId> = Some(value.sort_name)
.filter(|s| s != &value.name)
.map(Into::into);
LookupArtistResponse {
id: value.id.into(),
name: value.name.into(),
sort,
sort_name: value.sort_name.into(),
disambiguation: value.disambiguation,
release_groups: value
.release_groups
@ -111,7 +108,7 @@ impl From<DeserializeLookupArtistResponse> for LookupArtistResponse {
#[derive(Debug, PartialEq, Eq)]
pub struct LookupArtistResponseReleaseGroup {
pub id: Mbid,
pub title: String,
pub title: AlbumId,
pub first_release_date: AlbumDate,
pub primary_type: AlbumPrimaryType,
pub secondary_types: Vec<AlbumSecondaryType>,
@ -131,7 +128,7 @@ impl From<DeserializeLookupArtistResponseReleaseGroup> for LookupArtistResponseR
fn from(value: DeserializeLookupArtistResponseReleaseGroup) -> Self {
LookupArtistResponseReleaseGroup {
id: value.id.into(),
title: value.title,
title: value.title.into(),
first_release_date: value.first_release_date.into(),
primary_type: value.primary_type.into(),
secondary_types: value.secondary_types.into_iter().map(Into::into).collect(),
@ -217,7 +214,7 @@ mod tests {
let release_group = LookupArtistResponseReleaseGroup {
id: de_release_group.id.0,
title: de_release_group.title,
title: de_release_group.title.into(),
first_release_date: de_release_group.first_release_date.0,
primary_type: de_release_group.primary_type.0,
secondary_types: de_release_group
@ -229,7 +226,7 @@ mod tests {
let response = LookupArtistResponse {
id: de_id.0,
name: de_name.into(),
sort: Some(de_sort_name.into()),
sort_name: de_sort_name.into(),
disambiguation: de_disambiguation,
release_groups: vec![release_group],
};

View File

@ -50,7 +50,7 @@ pub struct SearchArtistResponseArtist {
pub score: u8,
pub id: Mbid,
pub name: ArtistId,
pub sort: Option<ArtistId>,
pub sort_name: ArtistId,
pub disambiguation: Option<String>,
}
@ -66,14 +66,11 @@ struct DeserializeSearchArtistResponseArtist {
impl From<DeserializeSearchArtistResponseArtist> for SearchArtistResponseArtist {
fn from(value: DeserializeSearchArtistResponseArtist) -> Self {
let sort: Option<ArtistId> = Some(value.sort_name)
.filter(|s| s != &value.name)
.map(Into::into);
SearchArtistResponseArtist {
score: value.score,
id: value.id.into(),
name: value.name.into(),
sort,
sort_name: value.sort_name.into(),
disambiguation: value.disambiguation,
}
}
@ -109,7 +106,7 @@ mod tests {
score: 67,
id: a.id.0,
name: a.name.clone().into(),
sort: Some(a.sort_name).filter(|sn| sn != &a.name).map(Into::into),
sort_name: a.sort_name.clone().into(),
disambiguation: a.disambiguation,
})
.collect(),

View File

@ -415,7 +415,7 @@ mod tests {
}
#[test]
fn select_manual_input() {
fn select_manual_input_empty() {
let matches =
AppMachine::match_state(inner(music_hoard(vec![])), match_state(Some(album_match())));
@ -428,6 +428,6 @@ mod tests {
let app = matches.select();
let input = app.mode().unwrap_input();
input.confirm().unwrap_match();
input.confirm().unwrap_error();
}
}

View File

@ -5,7 +5,7 @@ use std::collections::HashMap;
use musichoard::{
collection::{
album::{AlbumDate, AlbumMeta, AlbumSeq},
artist::ArtistMeta,
artist::{ArtistId, ArtistMeta},
musicbrainz::Mbid,
},
external::musicbrainz::{
@ -93,10 +93,13 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
}
fn from_lookup_artist_response(entity: LookupArtistResponse) -> Lookup<ArtistMeta> {
let sort: Option<ArtistId> = Some(entity.sort_name)
.filter(|s| s != &entity.name)
.map(Into::into);
Lookup {
item: ArtistMeta {
id: entity.name,
sort: entity.sort.map(Into::into),
sort,
musicbrainz: Some(entity.id.into()),
properties: HashMap::new(),
},
@ -119,11 +122,14 @@ fn from_lookup_release_group_response(entity: LookupReleaseGroupResponse) -> Loo
}
fn from_search_artist_response_artist(entity: SearchArtistResponseArtist) -> Match<ArtistMeta> {
let sort: Option<ArtistId> = Some(entity.sort_name)
.filter(|s| s != &entity.name)
.map(Into::into);
Match {
score: entity.score,
item: ArtistMeta {
id: entity.name,
sort: entity.sort.map(Into::into),
sort,
musicbrainz: Some(entity.id.into()),
properties: HashMap::new(),
},