Rename DbId to MbRef #242

Merged
wojtek merged 2 commits from 231---differentiate-release-groups-with-same-title-but-different-type-clash into main 2025-01-02 22:54:53 +01:00
17 changed files with 228 additions and 231 deletions
Showing only changes of commit 464e4c1014 - Show all commits

View File

@ -37,7 +37,7 @@ pub struct AlbumInfo {
pub struct AlbumId {
pub title: String,
pub lib_id: AlbumLibId,
pub db_id: AlbumDbId,
pub mb_ref: AlbumMbRef,
}
/// Unique library identifier.
@ -55,7 +55,7 @@ impl AlbumLibId {
}
/// Unique database identifier. Use MBID for this purpose.
pub type AlbumDbId = MbRefOption<MbAlbumRef>;
pub type AlbumMbRef = MbRefOption<MbAlbumRef>;
impl MergeName for Album {
fn name(&self) -> &str {
@ -221,12 +221,12 @@ impl AlbumMeta {
(&self.date, &self.seq, &self.id)
}
pub fn set_db_id(&mut self, db_id: AlbumDbId) {
self.id.set_db_id(db_id);
pub fn set_mb_ref(&mut self, mb_ref: AlbumMbRef) {
self.id.set_mb_ref(mb_ref);
}
pub fn clear_db_id(&mut self) {
self.id.clear_db_id();
pub fn clear_mb_ref(&mut self) {
self.id.clear_mb_ref();
}
pub fn set_seq(&mut self, seq: AlbumSeq) {
@ -265,7 +265,7 @@ impl Ord for AlbumMeta {
impl Merge for AlbumMeta {
fn merge_in_place(&mut self, other: Self) {
assert!(self.id.compatible(&other.id));
self.id.db_id = self.id.db_id.take().or(other.id.db_id);
self.id.mb_ref = self.id.mb_ref.take().or(other.id.mb_ref);
self.seq = std::cmp::max(self.seq, other.seq);
self.info.merge_in_place(other.info);
}
@ -297,30 +297,30 @@ impl AlbumId {
AlbumId {
title: name.into(),
lib_id: AlbumLibId::None,
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
}
}
pub fn with_db_id(mut self, db_id: AlbumDbId) -> Self {
self.db_id = db_id;
pub fn with_mb_ref(mut self, mb_ref: AlbumMbRef) -> Self {
self.mb_ref = mb_ref;
self
}
pub fn set_db_id(&mut self, db_id: AlbumDbId) {
self.db_id = db_id;
pub fn set_mb_ref(&mut self, mb_ref: AlbumMbRef) {
self.mb_ref = mb_ref;
}
pub fn clear_db_id(&mut self) {
self.db_id.take();
pub fn clear_mb_ref(&mut self) {
self.mb_ref.take();
}
pub fn compatible(&self, other: &AlbumId) -> bool {
let titles_compatible = self.title == other.title;
let lib_id_compatible =
self.lib_id.is_none() || other.lib_id.is_none() || (self.lib_id == other.lib_id);
let db_id_compatible =
self.db_id.is_none() || other.db_id.is_none() || (self.db_id == other.db_id);
titles_compatible && lib_id_compatible && db_id_compatible
let mb_ref_compatible =
self.mb_ref.is_none() || other.mb_ref.is_none() || (self.mb_ref == other.mb_ref);
titles_compatible && lib_id_compatible && mb_ref_compatible
}
}

View File

@ -40,11 +40,11 @@ impl MergeName for Artist {
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ArtistId {
pub name: String,
pub db_id: ArtistDbId,
pub mb_ref: ArtistMbRef,
}
/// Unique database identifier. Use MBID for this purpose.
pub type ArtistDbId = MbRefOption<MbArtistRef>;
pub type ArtistMbRef = MbRefOption<MbArtistRef>;
impl Artist {
/// Create new [`Artist`] with the given [`ArtistId`].
@ -120,12 +120,12 @@ impl ArtistMeta {
}
}
pub fn set_db_id(&mut self, db_id: ArtistDbId) {
self.id.set_db_id(db_id);
pub fn set_mb_ref(&mut self, mb_ref: ArtistMbRef) {
self.id.set_mb_ref(mb_ref);
}
pub fn clear_db_id(&mut self) {
self.id.clear_db_id();
pub fn clear_mb_ref(&mut self) {
self.id.clear_mb_ref();
}
pub fn get_sort_key(&self) -> (&str,) {
@ -202,7 +202,7 @@ impl Ord for ArtistMeta {
impl Merge for ArtistMeta {
fn merge_in_place(&mut self, other: Self) {
assert!(self.id.compatible(&other.id));
self.id.db_id = self.id.db_id.take().or(other.id.db_id);
self.id.mb_ref = self.id.mb_ref.take().or(other.id.mb_ref);
self.sort = self.sort.take().or(other.sort);
self.info.merge_in_place(other.info);
}
@ -230,28 +230,28 @@ impl ArtistId {
pub fn new<S: Into<String>>(name: S) -> ArtistId {
ArtistId {
name: name.into(),
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
}
}
pub fn with_db_id(mut self, db_id: ArtistDbId) -> Self {
self.db_id = db_id;
pub fn with_mb_ref(mut self, mb_ref: ArtistMbRef) -> Self {
self.mb_ref = mb_ref;
self
}
pub fn set_db_id(&mut self, db_id: ArtistDbId) {
self.db_id = db_id;
pub fn set_mb_ref(&mut self, mb_ref: ArtistMbRef) {
self.mb_ref = mb_ref;
}
pub fn clear_db_id(&mut self) {
self.db_id.take();
pub fn clear_mb_ref(&mut self) {
self.mb_ref.take();
}
pub fn compatible(&self, other: &ArtistId) -> bool {
let names_compatible = self.name == other.name;
let db_id_compatible =
self.db_id.is_none() || other.db_id.is_none() || (self.db_id == other.db_id);
names_compatible && db_id_compatible
let mb_ref_compatible =
self.mb_ref.is_none() || other.mb_ref.is_none() || (self.mb_ref == other.mb_ref);
names_compatible && mb_ref_compatible
}
}
@ -326,30 +326,30 @@ mod tests {
let mut artist = Artist::new(ArtistId::new("an artist"));
let mut expected: MbRefOption<MbArtistRef> = MbRefOption::None;
assert_eq!(artist.meta.id.db_id, expected);
assert_eq!(artist.meta.id.mb_ref, expected);
// Setting a URL on an artist.
artist.meta.id.set_db_id(MbRefOption::Some(
artist.meta.id.set_mb_ref(MbRefOption::Some(
MbArtistRef::from_url_str(MUSICBRAINZ).unwrap(),
));
expected.replace(MbArtistRef::from_url_str(MUSICBRAINZ).unwrap());
assert_eq!(artist.meta.id.db_id, expected);
assert_eq!(artist.meta.id.mb_ref, expected);
artist.meta.id.set_db_id(MbRefOption::Some(
artist.meta.id.set_mb_ref(MbRefOption::Some(
MbArtistRef::from_url_str(MUSICBRAINZ).unwrap(),
));
assert_eq!(artist.meta.id.db_id, expected);
assert_eq!(artist.meta.id.mb_ref, expected);
artist.meta.id.set_db_id(MbRefOption::Some(
artist.meta.id.set_mb_ref(MbRefOption::Some(
MbArtistRef::from_url_str(MUSICBRAINZ_2).unwrap(),
));
expected.replace(MbArtistRef::from_url_str(MUSICBRAINZ_2).unwrap());
assert_eq!(artist.meta.id.db_id, expected);
assert_eq!(artist.meta.id.mb_ref, expected);
// Clearing URLs.
artist.meta.id.clear_db_id();
artist.meta.id.clear_mb_ref();
expected.take();
assert_eq!(artist.meta.id.db_id, expected);
assert_eq!(artist.meta.id.mb_ref, expected);
}
#[test]
@ -465,7 +465,7 @@ mod tests {
let left = FULL_COLLECTION[0].to_owned();
let mut right = FULL_COLLECTION[1].to_owned();
right.meta.id = left.meta.id.clone();
right.meta.id.db_id = MbRefOption::None;
right.meta.id.mb_ref = MbRefOption::None;
right.meta.info.properties = HashMap::new();
let mut expected = left.clone();

View File

@ -2,8 +2,8 @@ use std::mem;
use crate::{
collection::{
album::{AlbumDbId, AlbumInfo, AlbumMeta},
artist::{ArtistDbId, ArtistInfo},
album::{AlbumInfo, AlbumMbRef, AlbumMeta},
artist::{ArtistInfo, ArtistMbRef},
merge::Merge,
},
core::{
@ -23,12 +23,12 @@ pub trait IMusicHoardDatabase {
fn add_artist<IntoId: Into<ArtistId>>(&mut self, artist_id: IntoId) -> Result<(), Error>;
fn remove_artist<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error>;
fn set_artist_db_id<Id: AsRef<ArtistId>>(
fn set_artist_mb_ref<Id: AsRef<ArtistId>>(
&mut self,
artist_id: Id,
db_id: ArtistDbId,
mb_ref: ArtistMbRef,
) -> Result<(), Error>;
fn clear_artist_db_id<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error>;
fn clear_artist_mb_ref<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error>;
fn set_artist_sort<Id: AsRef<ArtistId>, S: Into<String>>(
&mut self,
@ -79,13 +79,13 @@ pub trait IMusicHoardDatabase {
album_id: AlbumIdRef,
) -> Result<(), Error>;
fn set_album_db_id<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
fn set_album_mb_ref<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
&mut self,
artist_id: ArtistIdRef,
album_id: AlbumIdRef,
db_id: AlbumDbId,
mb_ref: AlbumMbRef,
) -> Result<(), Error>;
fn clear_album_db_id<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
fn clear_album_mb_ref<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
&mut self,
artist_id: ArtistIdRef,
album_id: AlbumIdRef,
@ -147,22 +147,22 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
})
}
fn set_artist_db_id<Id: AsRef<ArtistId>>(
fn set_artist_mb_ref<Id: AsRef<ArtistId>>(
&mut self,
artist_id: Id,
db_id: ArtistDbId,
mb_ref: ArtistMbRef,
) -> Result<(), Error> {
self.update_artist_and(
artist_id.as_ref(),
|artist| artist.meta.set_db_id(db_id),
|artist| artist.meta.set_mb_ref(mb_ref),
|collection| Self::sort_artists(collection),
)
}
fn clear_artist_db_id<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error> {
fn clear_artist_mb_ref<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error> {
self.update_artist_and(
artist_id.as_ref(),
|artist| artist.meta.clear_db_id(),
|artist| artist.meta.clear_mb_ref(),
|collection| Self::sort_artists(collection),
)
}
@ -280,21 +280,21 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
})
}
fn set_album_db_id<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
fn set_album_mb_ref<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
&mut self,
artist_id: ArtistIdRef,
album_id: AlbumIdRef,
db_id: AlbumDbId,
mb_ref: AlbumMbRef,
) -> Result<(), Error> {
self.update_album_and(
artist_id.as_ref(),
album_id.as_ref(),
|album| album.meta.set_db_id(db_id),
|album| album.meta.set_mb_ref(mb_ref),
|artist| artist.albums.sort_unstable(),
)
}
fn clear_album_db_id<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
fn clear_album_mb_ref<ArtistIdRef: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
&mut self,
artist_id: ArtistIdRef,
album_id: AlbumIdRef,
@ -302,7 +302,7 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
self.update_album_and(
artist_id.as_ref(),
album_id.as_ref(),
|album| album.meta.clear_db_id(),
|album| album.meta.clear_mb_ref(),
|artist| artist.albums.sort_unstable(),
)
}
@ -585,7 +585,7 @@ mod tests {
}
#[test]
fn set_clear_artist_db_id() {
fn set_clear_artist_mb_ref() {
let mut database = MockIDatabase::new();
database.expect_load().times(1).returning(|| Ok(vec![]));
database.expect_save().times(3).returning(|_| Ok(()));
@ -596,38 +596,38 @@ mod tests {
assert!(music_hoard.add_artist(artist_id.clone()).is_ok());
let mut expected = ArtistDbId::None;
assert_eq!(music_hoard.collection[0].meta.id.db_id, expected);
let mut expected = ArtistMbRef::None;
assert_eq!(music_hoard.collection[0].meta.id.mb_ref, expected);
let db_id = ArtistDbId::Some(MbArtistRef::from_uuid_str(MBID).unwrap());
let mb_ref = ArtistMbRef::Some(MbArtistRef::from_uuid_str(MBID).unwrap());
// Setting a db_id on an artist not in the collection is an error.
// Setting a mb_ref on an artist not in the collection is an error.
assert!(music_hoard
.set_artist_db_id(&artist_id_2, db_id.clone())
.set_artist_mb_ref(&artist_id_2, mb_ref.clone())
.is_err());
assert_eq!(music_hoard.collection[0].meta.id.db_id, expected);
assert_eq!(music_hoard.collection[0].meta.id.mb_ref, expected);
// Setting a db_id on an artist.
// Setting a mb_ref on an artist.
assert!(music_hoard
.set_artist_db_id(&artist_id, db_id.clone())
.set_artist_mb_ref(&artist_id, mb_ref.clone())
.is_ok());
expected.replace(MbArtistRef::from_uuid_str(MBID).unwrap());
assert_eq!(music_hoard.collection[0].meta.id.db_id, expected);
assert_eq!(music_hoard.collection[0].meta.id.mb_ref, expected);
// Clearing db_id on an artist that does not exist is an error.
assert!(music_hoard.clear_artist_db_id(&artist_id_2).is_err());
assert_eq!(music_hoard.collection[0].meta.id.db_id, expected);
// Clearing mb_ref on an artist that does not exist is an error.
assert!(music_hoard.clear_artist_mb_ref(&artist_id_2).is_err());
assert_eq!(music_hoard.collection[0].meta.id.mb_ref, expected);
// Clearing db_id from an artist without the db_id set is an error. Effectively the album
// Clearing mb_ref from an artist without the mb_ref set is an error. Effectively the album
// does not exist.
assert!(music_hoard.clear_artist_db_id(&artist_id).is_err());
assert_eq!(music_hoard.collection[0].meta.id.db_id, expected);
assert!(music_hoard.clear_artist_mb_ref(&artist_id).is_err());
assert_eq!(music_hoard.collection[0].meta.id.mb_ref, expected);
// Clearing db_id.
artist_id.set_db_id(db_id);
assert!(music_hoard.clear_artist_db_id(&artist_id).is_ok());
// Clearing mb_ref.
artist_id.set_mb_ref(mb_ref);
assert!(music_hoard.clear_artist_mb_ref(&artist_id).is_ok());
expected.take();
assert_eq!(music_hoard.collection[0].meta.id.db_id, expected);
assert_eq!(music_hoard.collection[0].meta.id.mb_ref, expected);
}
#[test]
@ -824,7 +824,7 @@ mod tests {
}
#[test]
fn set_clear_album_db_id() {
fn set_clear_album_mb_ref() {
let mut database = MockIDatabase::new();
let artist_id = ArtistId::new("an artist");
@ -842,40 +842,40 @@ mod tests {
let mut music_hoard = MusicHoard::database(database).unwrap();
let album = &music_hoard.collection[0].albums[0];
assert_eq!(album.meta.id.db_id, AlbumDbId::None);
assert_eq!(album.meta.id.mb_ref, AlbumMbRef::None);
// Seting db_id on an album not belonging to the artist is an error.
// Seting mb_ref on an album not belonging to the artist is an error.
assert!(music_hoard
.set_album_db_id(&artist_id, &album_id_2, AlbumDbId::CannotHaveMbid)
.set_album_mb_ref(&artist_id, &album_id_2, AlbumMbRef::CannotHaveMbid)
.is_err());
let album = &music_hoard.collection[0].albums[0];
assert_eq!(album.meta.id.db_id, AlbumDbId::None);
assert_eq!(album.meta.id.mb_ref, AlbumMbRef::None);
// Set db_id.
// Set mb_ref.
assert!(music_hoard
.set_album_db_id(&artist_id, &album_id, AlbumDbId::CannotHaveMbid)
.set_album_mb_ref(&artist_id, &album_id, AlbumMbRef::CannotHaveMbid)
.is_ok());
let album = &music_hoard.collection[0].albums[0];
assert_eq!(album.meta.id.db_id, AlbumDbId::CannotHaveMbid);
assert_eq!(album.meta.id.mb_ref, AlbumMbRef::CannotHaveMbid);
// Clearing db_id on an album that does not exist is an error.
// Clearing mb_ref on an album that does not exist is an error.
assert!(music_hoard
.clear_album_db_id(&artist_id, &album_id_2)
.clear_album_mb_ref(&artist_id, &album_id_2)
.is_err());
// Clearing db_id from an album without the db_id set is an error. Effectively the album
// Clearing mb_ref from an album without the mb_ref set is an error. Effectively the album
// does not exist.
assert!(music_hoard
.clear_album_db_id(&artist_id, &album_id)
.clear_album_mb_ref(&artist_id, &album_id)
.is_err());
let album = &music_hoard.collection[0].albums[0];
assert_eq!(album.meta.id.db_id, AlbumDbId::CannotHaveMbid);
assert_eq!(album.meta.id.mb_ref, AlbumMbRef::CannotHaveMbid);
// To clear the db_id we need the album_id to have the db_id to identify the correct album.
album_id.set_db_id(AlbumDbId::CannotHaveMbid);
assert!(music_hoard.clear_album_db_id(&artist_id, &album_id).is_ok());
// To clear the mb_ref we need the album_id to have the mb_ref to identify the correct album.
album_id.set_mb_ref(AlbumMbRef::CannotHaveMbid);
assert!(music_hoard.clear_album_mb_ref(&artist_id, &album_id).is_ok());
let album = &music_hoard.collection[0].albums[0];
assert_eq!(album.meta.id.db_id, AlbumDbId::None);
assert_eq!(album.meta.id.mb_ref, AlbumMbRef::None);
}
#[test]

View File

@ -1,11 +1,9 @@
use std::collections::HashMap;
use crate::{
collection::{album::AlbumDbId, artist::ArtistDbId},
core::{
use crate::core::{
collection::{
album::{Album, AlbumDate, AlbumId},
artist::{Artist, ArtistId},
album::{Album, AlbumDate, AlbumId, AlbumMbRef},
artist::{Artist, ArtistId, ArtistMbRef},
track::{Track, TrackId, TrackNum, TrackQuality},
Collection,
},
@ -17,7 +15,6 @@ use crate::{
base::IMusicHoardBasePrivate, database::IMusicHoardDatabasePrivate, Error, MusicHoard,
NoDatabase,
},
},
};
pub trait IMusicHoardLibrary {
@ -53,7 +50,7 @@ impl<Database, Library: ILibrary> MusicHoard<Database, Library> {
for item in items.into_iter() {
let artist_id = ArtistId {
name: item.album_artist,
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
};
let artist_sort = item.album_artist_sort;
@ -61,7 +58,7 @@ impl<Database, Library: ILibrary> MusicHoard<Database, Library> {
let album_id = AlbumId {
title: item.album_title,
lib_id: item.album_lib_id,
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
};
let album_date = AlbumDate {

View File

@ -3,9 +3,9 @@ use std::collections::HashMap;
use crate::core::collection::{
album::{
Album, AlbumDbId, AlbumId, AlbumInfo, AlbumLibId, AlbumMeta, AlbumPrimaryType, AlbumSeq,
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
},
artist::{Artist, ArtistDbId, ArtistId, ArtistInfo, ArtistMeta},
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::{MbAlbumRef, MbArtistRef},
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
};

View File

@ -125,7 +125,7 @@ impl From<DeserializeArtist> for Artist {
meta: ArtistMeta {
id: ArtistId {
name: artist.name,
db_id: artist.musicbrainz.into(),
mb_ref: artist.musicbrainz.into(),
},
sort: artist.sort,
info: ArtistInfo {
@ -144,7 +144,7 @@ impl From<DeserializeAlbum> for Album {
id: AlbumId {
title: album.title,
lib_id: album.lib_id.into(),
db_id: album.musicbrainz.into(),
mb_ref: album.musicbrainz.into(),
},
date: AlbumDate::default(),
seq: AlbumSeq(album.seq),

View File

@ -86,7 +86,7 @@ impl<'a> From<&'a Artist> for SerializeArtist<'a> {
SerializeArtist {
name: &artist.meta.id.name,
sort: artist.meta.sort.as_deref(),
musicbrainz: (&artist.meta.id.db_id).into(),
musicbrainz: (&artist.meta.id.mb_ref).into(),
properties: artist
.meta
.info
@ -105,7 +105,7 @@ impl<'a> From<&'a Album> for SerializeAlbum<'a> {
title: &album.meta.id.title,
lib_id: album.meta.id.lib_id.into(),
seq: album.meta.seq.0,
musicbrainz: (&album.meta.id.db_id).into(),
musicbrainz: (&album.meta.id.mb_ref).into(),
primary_type: album.meta.info.primary_type.map(Into::into),
secondary_types: album
.meta

View File

@ -5,7 +5,7 @@ macro_rules! full_collection {
meta: ArtistMeta {
id: ArtistId {
name: "Album_Artist A".to_string(),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/00000000-0000-0000-0000-000000000000"
).unwrap()),
},
@ -29,7 +29,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title a.a".to_string(),
lib_id: AlbumLibId::Value(1),
db_id: AlbumDbId::Some(MbAlbumRef::from_url_str(
mb_ref: AlbumMbRef::Some(MbAlbumRef::from_url_str(
"https://musicbrainz.org/release-group/00000000-0000-0000-0000-000000000000"
).unwrap()),
},
@ -95,7 +95,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title a.b".to_string(),
lib_id: AlbumLibId::Value(2),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: (2015, 4).into(),
seq: AlbumSeq(1),
@ -135,7 +135,7 @@ macro_rules! full_collection {
meta: ArtistMeta {
id: ArtistId {
name: "Album_Artist B".to_string(),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111"
).unwrap()),
},
@ -163,7 +163,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title b.a".to_string(),
lib_id: AlbumLibId::Value(3),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: (2003, 6, 6).into(),
seq: AlbumSeq(1),
@ -205,7 +205,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title b.b".to_string(),
lib_id: AlbumLibId::Value(4),
db_id: AlbumDbId::Some(MbAlbumRef::from_url_str(
mb_ref: AlbumMbRef::Some(MbAlbumRef::from_url_str(
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111111"
).unwrap()),
},
@ -249,7 +249,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title b.c".to_string(),
lib_id: AlbumLibId::Value(5),
db_id: AlbumDbId::Some(MbAlbumRef::from_url_str(
mb_ref: AlbumMbRef::Some(MbAlbumRef::from_url_str(
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111112"
).unwrap()),
},
@ -293,7 +293,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title b.d".to_string(),
lib_id: AlbumLibId::Value(6),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2015.into(),
seq: AlbumSeq(4),
@ -336,7 +336,7 @@ macro_rules! full_collection {
meta: ArtistMeta {
id: ArtistId {
name: "The Album_Artist C".to_string(),
db_id: ArtistDbId::CannotHaveMbid,
mb_ref: ArtistMbRef::CannotHaveMbid,
},
sort: Some("Album_Artist C, The".to_string()),
info: ArtistInfo {
@ -349,7 +349,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title c.a".to_string(),
lib_id: AlbumLibId::Value(7),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1985.into(),
seq: AlbumSeq(0),
@ -391,7 +391,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title c.b".to_string(),
lib_id: AlbumLibId::Value(8),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2018.into(),
seq: AlbumSeq(0),
@ -434,7 +434,7 @@ macro_rules! full_collection {
meta: ArtistMeta {
id: ArtistId {
name: "Album_Artist D".to_string(),
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
},
sort: None,
info: ArtistInfo {
@ -447,7 +447,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title d.a".to_string(),
lib_id: AlbumLibId::Value(9),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1995.into(),
seq: AlbumSeq(0),
@ -489,7 +489,7 @@ macro_rules! full_collection {
id: AlbumId {
title: "album_title d.b".to_string(),
lib_id: AlbumLibId::Value(10),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2028.into(),
seq: AlbumSeq(0),

View File

@ -6,7 +6,7 @@ macro_rules! library_collection {
meta: ArtistMeta {
id: ArtistId {
name: "Album_Artist A".to_string(),
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
},
sort: None,
info: ArtistInfo {
@ -19,7 +19,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title a.a".to_string(),
lib_id: AlbumLibId::Value(1),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1998.into(),
seq: AlbumSeq(0),
@ -80,7 +80,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title a.b".to_string(),
lib_id: AlbumLibId::Value(2),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: (2015, 4).into(),
seq: AlbumSeq(0),
@ -117,7 +117,7 @@ macro_rules! library_collection {
meta: ArtistMeta {
id: ArtistId {
name: "Album_Artist B".to_string(),
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
},
sort: None,
info: ArtistInfo {
@ -130,7 +130,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title b.a".to_string(),
lib_id: AlbumLibId::Value(3),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: (2003, 6, 6).into(),
seq: AlbumSeq(0),
@ -169,7 +169,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title b.b".to_string(),
lib_id: AlbumLibId::Value(4),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2008.into(),
seq: AlbumSeq(0),
@ -208,7 +208,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title b.c".to_string(),
lib_id: AlbumLibId::Value(5),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2009.into(),
seq: AlbumSeq(0),
@ -247,7 +247,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title b.d".to_string(),
lib_id: AlbumLibId::Value(6),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2015.into(),
seq: AlbumSeq(0),
@ -287,7 +287,7 @@ macro_rules! library_collection {
meta: ArtistMeta {
id: ArtistId {
name: "The Album_Artist C".to_string(),
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
},
sort: Some("Album_Artist C, The".to_string()),
info: ArtistInfo {
@ -300,7 +300,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title c.a".to_string(),
lib_id: AlbumLibId::Value(7),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1985.into(),
seq: AlbumSeq(0),
@ -339,7 +339,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title c.b".to_string(),
lib_id: AlbumLibId::Value(8),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2018.into(),
seq: AlbumSeq(0),
@ -379,7 +379,7 @@ macro_rules! library_collection {
meta: ArtistMeta {
id: ArtistId {
name: "Album_Artist D".to_string(),
db_id: ArtistDbId::None,
mb_ref: ArtistMbRef::None,
},
sort: None,
info: ArtistInfo {
@ -392,7 +392,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title d.a".to_string(),
lib_id: AlbumLibId::Value(9),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1995.into(),
seq: AlbumSeq(0),
@ -431,7 +431,7 @@ macro_rules! library_collection {
id: AlbumId {
title: "album_title d.b".to_string(),
lib_id: AlbumLibId::Value(10),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2028.into(),
seq: AlbumSeq(0),

View File

@ -115,14 +115,14 @@ impl AppMachine<FetchState> {
let mut requests = Self::search_artist_job(artist);
if requests.is_empty() {
fetch = FetchState::fetch(rx);
requests = Self::browse_release_group_job(&artist.meta.id.db_id);
requests = Self::browse_release_group_job(&artist.meta.id.mb_ref);
} else {
fetch = FetchState::search(rx);
}
SubmitJob { fetch, requests }
}
_ => {
let arid = match artist.meta.id.db_id {
let arid = match artist.meta.id.mb_ref {
MbRefOption::Some(ref mbref) => mbref,
_ => return Err("cannot fetch album: artist has no MBID"),
};
@ -213,7 +213,7 @@ impl AppMachine<FetchState> {
}
fn album_match(old: &AlbumMeta, new: &AlbumMeta) -> bool {
old.id.db_id.is_some() && (old.id.db_id == new.id.db_id)
old.id.mb_ref.is_some() && (old.id.mb_ref == new.id.mb_ref)
}
pub fn app_lookup_artist(
@ -258,7 +258,7 @@ impl AppMachine<FetchState> {
}
fn search_artist_job(artist: &Artist) -> VecDeque<MbParams> {
match artist.meta.id.db_id {
match artist.meta.id.mb_ref {
MbRefOption::Some(ref arid) => {
Self::search_albums_requests(&artist.meta.id, arid, &artist.albums)
}
@ -287,7 +287,7 @@ impl AppMachine<FetchState> {
let arid = arid.mbid();
albums
.iter()
.filter(|album| album.meta.id.db_id.is_none())
.filter(|album| album.meta.id.mb_ref.is_none())
.map(|album| {
MbParams::search_release_group(artist.clone(), arid.clone(), album.meta.clone())
})
@ -784,7 +784,7 @@ mod tests {
}
fn browse_release_group_expectation(artist: &Artist) -> MockIMbJobSender {
let requests = AppMachine::browse_release_group_job(&artist.meta.id.db_id);
let requests = AppMachine::browse_release_group_job(&artist.meta.id.mb_ref);
let mut mb_job_sender = MockIMbJobSender::new();
mb_job_sender
.expect_submit_background_job()

View File

@ -1,8 +1,8 @@
use std::cmp;
use musichoard::collection::{
album::{AlbumDbId, AlbumInfo, AlbumMeta},
artist::{ArtistDbId, ArtistInfo, ArtistMeta},
album::{AlbumInfo, AlbumMbRef, AlbumMeta},
artist::{ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::{MbRefOption, Mbid},
};
@ -13,12 +13,12 @@ use crate::tui::app::{
};
struct ArtistInfoTuple {
db_id: ArtistDbId,
mb_ref: ArtistMbRef,
info: ArtistInfo,
}
struct AlbumInfoTuple {
db_id: AlbumDbId,
mb_ref: AlbumMbRef,
info: AlbumInfo,
}
@ -46,17 +46,17 @@ impl GetInfo for MatchOption<ArtistMeta> {
type InfoType = ArtistInfoTuple;
fn get_info(&self) -> InfoOption<Self::InfoType> {
let db_id;
let mb_ref;
let mut info = ArtistInfo::default();
match self {
MatchOption::Some(option) => {
db_id = option.entity.id.db_id.clone();
mb_ref = option.entity.id.mb_ref.clone();
info = option.entity.info.clone();
}
MatchOption::CannotHaveMbid => db_id = MbRefOption::CannotHaveMbid,
MatchOption::CannotHaveMbid => mb_ref = MbRefOption::CannotHaveMbid,
MatchOption::ManualInputMbid => return InfoOption::NeedInput,
}
InfoOption::Info(ArtistInfoTuple { db_id, info })
InfoOption::Info(ArtistInfoTuple { mb_ref, info })
}
}
@ -64,17 +64,17 @@ impl GetInfo for MatchOption<AlbumMeta> {
type InfoType = AlbumInfoTuple;
fn get_info(&self) -> InfoOption<Self::InfoType> {
let db_id;
let mb_ref;
let mut info = AlbumInfo::default();
match self {
MatchOption::Some(option) => {
db_id = option.entity.id.db_id.clone();
mb_ref = option.entity.id.mb_ref.clone();
info = option.entity.info.clone();
}
MatchOption::CannotHaveMbid => db_id = AlbumDbId::CannotHaveMbid,
MatchOption::CannotHaveMbid => mb_ref = AlbumMbRef::CannotHaveMbid,
MatchOption::ManualInputMbid => return InfoOption::NeedInput,
}
InfoOption::Info(AlbumInfoTuple { db_id, info })
InfoOption::Info(AlbumInfoTuple { mb_ref, info })
}
}
@ -248,14 +248,14 @@ impl IAppInteractMatch for AppMachine<MatchState> {
EntityMatches::Artist(ref mut matches) => match matches.list.extract_info(index) {
InfoOption::Info(tuple) => mh
.merge_artist_info(&matches.matching.id, tuple.info)
.and_then(|()| mh.set_artist_db_id(&matches.matching.id, tuple.db_id)),
.and_then(|()| mh.set_artist_mb_ref(&matches.matching.id, tuple.mb_ref)),
InfoOption::NeedInput => return self.get_input(),
},
EntityMatches::Album(ref mut matches) => match matches.list.extract_info(index) {
InfoOption::Info(tuple) => mh
.merge_album_info(&matches.artist, &matches.matching, tuple.info)
.and_then(|()| {
mh.set_album_db_id(&matches.artist, &matches.matching, tuple.db_id)
mh.set_album_mb_ref(&matches.artist, &matches.matching, tuple.mb_ref)
}),
InfoOption::NeedInput => return self.get_input(),
},
@ -314,7 +314,7 @@ mod tests {
}
fn artist_meta() -> ArtistMeta {
ArtistMeta::new(ArtistId::new("Artist").with_db_id(ArtistDbId::Some(mbid().into())))
ArtistMeta::new(ArtistId::new("Artist").with_mb_ref(ArtistMbRef::Some(mbid().into())))
}
fn artist_match() -> EntityMatches {
@ -327,20 +327,20 @@ mod tests {
let mut artist_match_2 = Entity::with_score(artist_2, 100);
artist_match_2.disambiguation = Some(String::from("some disambiguation"));
artist.clear_db_id();
artist.clear_mb_ref();
let list = vec![artist_match_1.clone(), artist_match_2.clone()];
EntityMatches::artist_search(artist, list)
}
fn artist_lookup() -> EntityMatches {
let mut artist = artist_meta();
artist.clear_db_id();
artist.clear_mb_ref();
let lookup = Entity::new(artist.clone());
EntityMatches::artist_lookup(artist, lookup)
}
fn album_id() -> AlbumId {
AlbumId::new("Album").with_db_id(MbRefOption::Some(mbid().into()))
AlbumId::new("Album").with_mb_ref(MbRefOption::Some(mbid().into()))
}
fn album_meta(id: AlbumId) -> AlbumMeta {
@ -365,7 +365,7 @@ mod tests {
album_2.info.secondary_types.pop();
let album_match_2 = Entity::with_score(album_2, 100);
album_id.clear_db_id();
album_id.clear_mb_ref();
let list = vec![album_match_1.clone(), album_match_2.clone()];
EntityMatches::album_search(artist_id, album_id, list)
}
@ -375,7 +375,7 @@ mod tests {
let mut album_id = album_id();
let album_meta = album_meta(album_id.clone());
album_id.clear_db_id();
album_id.clear_mb_ref();
let lookup = Entity::new(album_meta.clone());
EntityMatches::album_lookup(artist_id, album_id, lookup)
}
@ -420,7 +420,7 @@ mod tests {
match matches_info {
EntityMatches::Album(_) => {
let album_id = AlbumId::new("Album");
let db_id = MbRefOption::CannotHaveMbid;
let mb_ref = MbRefOption::CannotHaveMbid;
let info = AlbumInfo::default();
let mut seq = Sequence::new();
@ -431,14 +431,14 @@ mod tests {
.in_sequence(&mut seq)
.return_once(|_, _, _| Ok(()));
music_hoard
.expect_set_album_db_id()
.with(eq(artist_id.clone()), eq(album_id.clone()), eq(db_id))
.expect_set_album_mb_ref()
.with(eq(artist_id.clone()), eq(album_id.clone()), eq(mb_ref))
.times(1)
.in_sequence(&mut seq)
.return_once(|_, _, _| Ok(()));
}
EntityMatches::Artist(_) => {
let db_id = MbRefOption::CannotHaveMbid;
let mb_ref = MbRefOption::CannotHaveMbid;
let info = ArtistInfo::default();
let mut seq = Sequence::new();
@ -449,8 +449,8 @@ mod tests {
.in_sequence(&mut seq)
.return_once(|_, _| Ok(()));
music_hoard
.expect_set_artist_db_id()
.with(eq(artist_id.clone()), eq(db_id))
.expect_set_artist_mb_ref()
.with(eq(artist_id.clone()), eq(mb_ref))
.times(1)
.in_sequence(&mut seq)
.return_once(|_, _| Ok(()));
@ -533,8 +533,8 @@ mod tests {
EntityMatches::Album(_) => panic!(),
EntityMatches::Artist(_) => {
let mut meta = artist_meta();
let db_id = meta.id.db_id.clone();
meta.clear_db_id();
let mb_ref = meta.id.mb_ref.clone();
meta.clear_mb_ref();
let mut seq = Sequence::new();
music_hoard
@ -544,8 +544,8 @@ mod tests {
.in_sequence(&mut seq)
.return_once(|_, _| Ok(()));
music_hoard
.expect_set_artist_db_id()
.with(eq(meta.id.clone()), eq(db_id))
.expect_set_artist_mb_ref()
.with(eq(meta.id.clone()), eq(mb_ref))
.times(1)
.in_sequence(&mut seq)
.return_once(|_, _| Ok(()));
@ -569,8 +569,8 @@ mod tests {
EntityMatches::Album(matches) => {
let mut album_id = album_id();
let meta = album_meta(album_id.clone());
let db_id = album_id.db_id.clone();
album_id.clear_db_id();
let mb_ref = album_id.mb_ref.clone();
album_id.clear_mb_ref();
let artist = matches.artist.clone();
let mut seq = Sequence::new();
@ -581,8 +581,8 @@ mod tests {
.in_sequence(&mut seq)
.return_once(|_, _, _| Ok(()));
music_hoard
.expect_set_album_db_id()
.with(eq(artist.clone()), eq(album_id.clone()), eq(db_id))
.expect_set_album_mb_ref()
.with(eq(artist.clone()), eq(album_id.clone()), eq(mb_ref))
.times(1)
.in_sequence(&mut seq)
.return_once(|_, _, _| Ok(()));

View File

@ -4,9 +4,9 @@ use std::collections::HashMap;
use musichoard::{
collection::{
album::{AlbumDate, AlbumDbId, AlbumId, AlbumInfo, AlbumLibId, AlbumMeta, AlbumSeq},
artist::{ArtistId, ArtistInfo, ArtistMeta},
musicbrainz::{MbRefOption, Mbid},
album::{AlbumDate, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumSeq},
artist::{ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::Mbid,
},
external::musicbrainz::{
api::{
@ -117,7 +117,7 @@ fn from_mb_artist_meta(meta: MbArtistMeta) -> (ArtistMeta, Option<String>) {
ArtistMeta {
id: ArtistId {
name: meta.name,
db_id: MbRefOption::Some(meta.id.into()),
mb_ref: ArtistMbRef::Some(meta.id.into()),
},
sort,
info: ArtistInfo {
@ -133,7 +133,7 @@ fn from_mb_release_group_meta(meta: MbReleaseGroupMeta) -> AlbumMeta {
id: AlbumId {
title: meta.title,
lib_id: AlbumLibId::None,
db_id: AlbumDbId::Some(meta.id.into()),
mb_ref: AlbumMbRef::Some(meta.id.into()),
},
date: meta.first_release_date,
seq: AlbumSeq::default(),

View File

@ -454,7 +454,7 @@ mod tests {
}
fn search_albums_requests() -> VecDeque<MbParams> {
let mbref = mb_ref_opt_as_ref(&COLLECTION[1].meta.id.db_id);
let mbref = mb_ref_opt_as_ref(&COLLECTION[1].meta.id.mb_ref);
let arid = mb_ref_opt_unwrap(mbref).mbid().clone();
let artist_id = COLLECTION[1].meta.id.clone();
@ -468,7 +468,7 @@ mod tests {
}
fn browse_albums_requests() -> VecDeque<MbParams> {
let mbref = mb_ref_opt_as_ref(&COLLECTION[1].meta.id.db_id);
let mbref = mb_ref_opt_as_ref(&COLLECTION[1].meta.id.mb_ref);
let arid = mb_ref_opt_unwrap(mbref).mbid().clone();
VecDeque::from([MbParams::browse_release_group(arid)])
}
@ -478,7 +478,7 @@ mod tests {
}
fn album_arid_expectation() -> Mbid {
let mbref = mb_ref_opt_as_ref(&COLLECTION[1].meta.id.db_id);
let mbref = mb_ref_opt_as_ref(&COLLECTION[1].meta.id.mb_ref);
mb_ref_opt_unwrap(mbref).mbid().clone()
}

View File

@ -3,8 +3,8 @@ pub mod interface;
use musichoard::{
collection::{
album::{AlbumDbId, AlbumId, AlbumInfo, AlbumMeta},
artist::{ArtistDbId, ArtistId, ArtistInfo},
album::{AlbumId, AlbumInfo, AlbumMbRef, AlbumMeta},
artist::{ArtistId, ArtistInfo, ArtistMbRef},
Collection,
},
interface::{database::IDatabase, library::ILibrary},
@ -26,21 +26,21 @@ pub trait IMusicHoard {
album_meta: AlbumMeta,
) -> Result<(), musichoard::Error>;
fn set_artist_db_id(
fn set_artist_mb_ref(
&mut self,
artist_id: &ArtistId,
db_id: ArtistDbId,
mb_ref: ArtistMbRef,
) -> Result<(), musichoard::Error>;
fn merge_artist_info(
&mut self,
id: &ArtistId,
info: ArtistInfo,
) -> Result<(), musichoard::Error>;
fn set_album_db_id(
fn set_album_mb_ref(
&mut self,
artist_id: &ArtistId,
album_id: &AlbumId,
db_id: AlbumDbId,
mb_ref: AlbumMbRef,
) -> Result<(), musichoard::Error>;
fn merge_album_info(
&mut self,
@ -72,12 +72,12 @@ impl<Database: IDatabase, Library: ILibrary> IMusicHoard for MusicHoard<Database
<Self as IMusicHoardDatabase>::add_album(self, artist_id, album_meta)
}
fn set_artist_db_id(
fn set_artist_mb_ref(
&mut self,
artist_id: &ArtistId,
db_id: ArtistDbId,
mb_ref: ArtistMbRef,
) -> Result<(), musichoard::Error> {
<Self as IMusicHoardDatabase>::set_artist_db_id(self, artist_id, db_id)
<Self as IMusicHoardDatabase>::set_artist_mb_ref(self, artist_id, mb_ref)
}
fn merge_artist_info(
@ -88,13 +88,13 @@ impl<Database: IDatabase, Library: ILibrary> IMusicHoard for MusicHoard<Database
<Self as IMusicHoardDatabase>::merge_artist_info(self, id, info)
}
fn set_album_db_id(
fn set_album_mb_ref(
&mut self,
artist_id: &ArtistId,
album_id: &AlbumId,
db_id: AlbumDbId,
mb_ref: AlbumMbRef,
) -> Result<(), musichoard::Error> {
<Self as IMusicHoardDatabase>::set_album_db_id(self, artist_id, album_id, db_id)
<Self as IMusicHoardDatabase>::set_album_mb_ref(self, artist_id, album_id, mb_ref)
}
fn merge_album_info(

View File

@ -2,9 +2,9 @@ use std::collections::HashMap;
use musichoard::collection::{
album::{
Album, AlbumDbId, AlbumId, AlbumInfo, AlbumLibId, AlbumMeta, AlbumPrimaryType, AlbumSeq,
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
},
artist::{Artist, ArtistDbId, ArtistId, ArtistInfo, ArtistMeta},
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::{MbAlbumRef, MbArtistRef},
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
};

View File

@ -76,7 +76,7 @@ impl<'a> ArtistOverlay<'a> {
Properties: {}",
artist.map(|a| a.meta.id.name.as_str()).unwrap_or(""),
artist
.map(|a| UiDisplay::display_mb_ref_option_as_url(&a.meta.id.db_id))
.map(|a| UiDisplay::display_mb_ref_option_as_url(&a.meta.id.mb_ref))
.unwrap_or_default(),
Self::opt_hashmap_to_string(
artist.map(|a| &a.meta.info.properties),
@ -108,7 +108,7 @@ impl<'a> AlbumOverlay<'a> {
.map(|a| UiDisplay::display_album_lib_id(&a.meta.id.lib_id))
.unwrap_or_default(),
album
.map(|a| UiDisplay::display_mb_ref_option_as_url(&a.meta.id.db_id))
.map(|a| UiDisplay::display_mb_ref_option_as_url(&a.meta.id.mb_ref))
.unwrap_or_default(),
));

View File

@ -3,10 +3,10 @@ use std::collections::HashMap;
use musichoard::collection::{
album::{
Album, AlbumDbId, AlbumId, AlbumInfo, AlbumLibId, AlbumMeta, AlbumPrimaryType,
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType,
AlbumSecondaryType, AlbumSeq,
},
artist::{Artist, ArtistDbId, ArtistId, ArtistInfo, ArtistMeta},
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::MbArtistRef,
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
Collection,
@ -18,7 +18,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
meta: ArtistMeta {
id: ArtistId {
name: String::from("Аркона"),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/baad262d-55ef-427a-83c7-f7530964f212"
).unwrap()),
},
@ -42,7 +42,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("Slovo"),
lib_id: AlbumLibId::Value(7),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2011.into(),
seq: AlbumSeq(0),
@ -213,7 +213,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
meta: ArtistMeta {
id: ArtistId {
name: String::from("Eluveitie"),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/8000598a-5edb-401c-8e6d-36b167feaf38"
).unwrap()),
},
@ -235,7 +235,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("Vên [rerecorded]"),
lib_id: AlbumLibId::Value(1),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2004.into(),
seq: AlbumSeq(0),
@ -318,7 +318,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("Slania"),
lib_id: AlbumLibId::Value(2),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2008.into(),
seq: AlbumSeq(0),
@ -468,7 +468,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
meta: ArtistMeta {
id: ArtistId {
name: String::from("Frontside"),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/3a901353-fccd-4afd-ad01-9c03f451b490"
).unwrap()),
},
@ -489,7 +489,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"),
lib_id: AlbumLibId::Value(3),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2001.into(),
seq: AlbumSeq(0),
@ -627,7 +627,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
meta: ArtistMeta {
id: ArtistId {
name: String::from("Heavens Basement"),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/c2c4d56a-d599-4a18-bd2f-ae644e2198cc"
).unwrap()),
},
@ -648,7 +648,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("Paper Plague"),
lib_id: AlbumLibId::Singleton,
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2011.into(),
seq: AlbumSeq(0),
@ -672,7 +672,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("Unbreakable"),
lib_id: AlbumLibId::Value(4),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 2011.into(),
seq: AlbumSeq(0),
@ -766,7 +766,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
meta: ArtistMeta {
id: ArtistId {
name: String::from("Metallica"),
db_id: ArtistDbId::Some(MbArtistRef::from_url_str(
mb_ref: ArtistMbRef::Some(MbArtistRef::from_url_str(
"https://musicbrainz.org/artist/65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab"
).unwrap()),
},
@ -788,7 +788,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("Ride the Lightning"),
lib_id: AlbumLibId::Value(5),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1984.into(),
seq: AlbumSeq(0),
@ -893,7 +893,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
id: AlbumId {
title: String::from("S&M"),
lib_id: AlbumLibId::Value(6),
db_id: AlbumDbId::None,
mb_ref: AlbumMbRef::None,
},
date: 1999.into(),
seq: AlbumSeq(0),