Remove album status from all types
Some checks failed
Cargo CI / Lint (pull_request) Successful in 1m6s
Cargo CI / Build and Test (pull_request) Failing after 54s

This commit is contained in:
Wojciech Kozlowski 2025-01-03 20:21:45 +01:00
parent 1a5007459f
commit 3970271922
15 changed files with 9 additions and 153 deletions

View File

@ -27,7 +27,6 @@ pub struct AlbumMeta {
/// Album non-identifier metadata.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct AlbumInfo {
pub status: Option<AlbumStatus>,
pub primary_type: Option<AlbumPrimaryType>,
pub secondary_types: Vec<AlbumSecondaryType>,
}
@ -94,23 +93,6 @@ impl From<(u32, u8, u8)> for AlbumDate {
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
pub struct AlbumSeq(pub u8);
/// Based on [MusicBrainz status](https://musicbrainz.org/doc/Release#Status).
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum AlbumStatus {
/// Official
Official,
/// Promotion
Promotion,
/// Bootleg
Bootleg,
/// Pseudo-release
PseudoRelease,
/// Withdrawn
Withdrawn,
/// Cancelled
Cancelled,
}
/// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type).
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum AlbumPrimaryType {
@ -256,12 +238,10 @@ impl AlbumMeta {
impl AlbumInfo {
pub fn new(
status: Option<AlbumStatus>,
primary_type: Option<AlbumPrimaryType>,
secondary_types: Vec<AlbumSecondaryType>,
) -> Self {
AlbumInfo {
status,
primary_type,
secondary_types,
}
@ -294,7 +274,6 @@ impl Merge for AlbumMeta {
impl Merge for AlbumInfo {
fn merge_in_place(&mut self, other: Self) {
self.status = self.status.take().or(other.status);
self.primary_type = self.primary_type.take().or(other.primary_type);
if self.secondary_types.is_empty() {
self.secondary_types = other.secondary_types;

View File

@ -453,7 +453,7 @@ mod tests {
use crate::{
collection::{
album::{AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
album::{AlbumPrimaryType, AlbumSecondaryType},
musicbrainz::MbArtistRef,
},
core::{
@ -944,7 +944,6 @@ mod tests {
assert_eq!(meta.info.secondary_types, Vec::new());
let info = AlbumInfo::new(
Some(AlbumStatus::Official),
Some(AlbumPrimaryType::Album),
vec![AlbumSecondaryType::Live],
);

View File

@ -4,7 +4,6 @@ use std::collections::HashMap;
use crate::core::collection::{
album::{
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
AlbumStatus,
},
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::{MbAlbumRef, MbArtistRef},

View File

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use crate::core::collection::{
album::{AlbumDate, AlbumLibId, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
album::{AlbumDate, AlbumLibId, AlbumPrimaryType, AlbumSecondaryType},
musicbrainz::MbRefOption,
};
@ -59,32 +59,6 @@ pub enum MbRefOptionDef<T> {
None,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(remote = "AlbumStatus")]
pub enum AlbumStatusDef {
Official,
Promotion,
Bootleg,
PseudoRelease,
Withdrawn,
Cancelled,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SerdeAlbumStatus(#[serde(with = "AlbumStatusDef")] AlbumStatus);
impl From<SerdeAlbumStatus> for AlbumStatus {
fn from(value: SerdeAlbumStatus) -> Self {
value.0
}
}
impl From<AlbumStatus> for SerdeAlbumStatus {
fn from(value: AlbumStatus) -> Self {
SerdeAlbumStatus(value)
}
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(remote = "AlbumPrimaryType")]
pub enum AlbumPrimaryTypeDef {

View File

@ -11,7 +11,7 @@ use crate::{
},
external::database::serde::common::{
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
SerdeAlbumSecondaryType, SerdeAlbumStatus,
SerdeAlbumSecondaryType,
},
};
@ -46,7 +46,6 @@ pub struct DeserializeAlbum {
date: SerdeAlbumDate,
seq: u8,
musicbrainz: DeserializeMbRefOption,
status: Option<SerdeAlbumStatus>,
primary_type: Option<SerdeAlbumPrimaryType>,
secondary_types: Vec<SerdeAlbumSecondaryType>,
}
@ -139,7 +138,6 @@ impl From<DeserializeAlbum> for Album {
date: album.date.into(),
seq: AlbumSeq(album.seq),
info: AlbumInfo {
status: album.status.map(Into::into),
primary_type: album.primary_type.map(Into::into),
secondary_types: album.secondary_types.into_iter().map(Into::into).collect(),
},

View File

@ -7,7 +7,7 @@ use crate::{
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
external::database::serde::common::{
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
SerdeAlbumSecondaryType, SerdeAlbumStatus,
SerdeAlbumSecondaryType,
},
};
@ -38,7 +38,6 @@ pub struct SerializeAlbum<'a> {
date: SerdeAlbumDate,
seq: u8,
musicbrainz: SerializeMbRefOption<'a>,
status: Option<SerdeAlbumStatus>,
primary_type: Option<SerdeAlbumPrimaryType>,
secondary_types: Vec<SerdeAlbumSecondaryType>,
}
@ -98,7 +97,6 @@ impl<'a> From<&'a Album> for SerializeAlbum<'a> {
date: album.meta.date.into(),
seq: album.meta.seq.0,
musicbrainz: (&album.meta.id.mb_ref).into(),
status: album.meta.info.status.map(Into::into),
primary_type: album.meta.info.primary_type.map(Into::into),
secondary_types: album
.meta

View File

@ -4,7 +4,7 @@ use serde::{de::Visitor, Deserialize, Deserializer};
use crate::{
collection::{
album::{AlbumDate, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
album::{AlbumDate, AlbumPrimaryType, AlbumSecondaryType},
musicbrainz::Mbid,
Error as CollectionError,
},
@ -131,7 +131,6 @@ pub struct MbReleaseGroupMeta {
pub id: Mbid,
pub title: String,
pub first_release_date: AlbumDate,
pub status: Option<AlbumStatus>,
pub primary_type: Option<AlbumPrimaryType>,
pub secondary_types: Option<Vec<AlbumSecondaryType>>,
}
@ -142,7 +141,6 @@ pub struct SerdeMbReleaseGroupMeta {
id: SerdeMbid,
title: String,
first_release_date: SerdeAlbumDate,
status: Option<SerdeAlbumStatus>,
primary_type: Option<SerdeAlbumPrimaryType>,
secondary_types: Option<Vec<SerdeAlbumSecondaryType>>,
}
@ -153,7 +151,6 @@ impl From<SerdeMbReleaseGroupMeta> for MbReleaseGroupMeta {
id: value.id.into(),
title: value.title,
first_release_date: value.first_release_date.into(),
status: value.status.map(Into::into),
primary_type: value.primary_type.map(Into::into),
secondary_types: value
.secondary_types
@ -284,26 +281,6 @@ impl<'de> Deserialize<'de> for SerdeAlbumDate {
}
}
#[derive(Debug, Deserialize)]
#[serde(remote = "AlbumStatus", rename_all(deserialize = "kebab-case"))]
pub enum AlbumStatusDef {
Official,
Promotion,
Bootleg,
PseudoRelease,
Withdrawn,
Cancelled,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SerdeAlbumStatus(#[serde(with = "AlbumStatusDef")] AlbumStatus);
impl From<SerdeAlbumStatus> for AlbumStatus {
fn from(value: SerdeAlbumStatus) -> Self {
value.0
}
}
#[derive(Debug, Deserialize)]
#[serde(remote = "AlbumPrimaryType")]
pub enum AlbumPrimaryTypeDef {

View File

@ -36,7 +36,6 @@ macro_rules! full_collection {
date: 1998.into(),
seq: AlbumSeq(1),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -101,7 +100,6 @@ macro_rules! full_collection {
date: (2015, 4).into(),
seq: AlbumSeq(1),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -170,7 +168,6 @@ macro_rules! full_collection {
date: (2003, 6, 6).into(),
seq: AlbumSeq(1),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -215,7 +212,6 @@ macro_rules! full_collection {
date: 2008.into(),
seq: AlbumSeq(3),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -260,7 +256,6 @@ macro_rules! full_collection {
date: 2009.into(),
seq: AlbumSeq(2),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -303,7 +298,6 @@ macro_rules! full_collection {
date: 2015.into(),
seq: AlbumSeq(4),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -360,7 +354,6 @@ macro_rules! full_collection {
date: 1985.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -403,7 +396,6 @@ macro_rules! full_collection {
date: 2018.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -460,7 +452,6 @@ macro_rules! full_collection {
date: 1995.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -503,7 +494,6 @@ macro_rules! full_collection {
date: 2028.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},

View File

@ -282,7 +282,7 @@ mod tests {
Sequence,
};
use musichoard::collection::{
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType},
artist::{ArtistId, ArtistMeta},
};
@ -347,7 +347,6 @@ mod tests {
AlbumMeta::new(id)
.with_date(AlbumDate::new(Some(1990), Some(5), None))
.with_info(AlbumInfo::new(
Some(AlbumStatus::Official),
Some(AlbumPrimaryType::Album),
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
))

View File

@ -138,7 +138,6 @@ fn from_mb_release_group_meta(meta: MbReleaseGroupMeta) -> AlbumMeta {
date: meta.first_release_date,
seq: AlbumSeq::default(),
info: AlbumInfo {
status: meta.status,
primary_type: meta.primary_type,
secondary_types: meta.secondary_types.unwrap_or_default(),
},

View File

@ -3,7 +3,6 @@ use std::collections::HashMap;
use musichoard::collection::{
album::{
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
AlbumStatus,
},
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::{MbAlbumRef, MbArtistRef},

View File

@ -163,7 +163,6 @@ impl<'a, 'b> AlbumState<'a, 'b> {
"Title: {}\n\
Date: {}\n\
Type: {}\n\
Status: {}\n\
Ownership: {}",
album.map(|a| a.meta.id.title.as_str()).unwrap_or(""),
album
@ -175,9 +174,6 @@ impl<'a, 'b> AlbumState<'a, 'b> {
&a.meta.info.secondary_types
))
.unwrap_or_default(),
album
.map(|a| UiDisplay::display_album_status(&a.meta.info.status))
.unwrap_or(""),
album
.map(|a| UiDisplay::display_album_ownership(&a.get_ownership()))
.unwrap_or("")

View File

@ -1,7 +1,7 @@
use musichoard::collection::{
album::{
AlbumDate, AlbumId, AlbumLibId, AlbumMeta, AlbumOwnership, AlbumPrimaryType,
AlbumSecondaryType, AlbumSeq, AlbumStatus,
AlbumSecondaryType, AlbumSeq,
},
artist::ArtistMeta,
musicbrainz::{IMusicBrainzRef, MbRefOption},
@ -50,20 +50,6 @@ impl UiDisplay {
}
}
pub fn display_album_status(value: &Option<AlbumStatus>) -> &'static str {
match value {
Some(status) => match status {
AlbumStatus::Official => "Official",
AlbumStatus::Promotion => "Promotion",
AlbumStatus::Bootleg => "Bootleg",
AlbumStatus::PseudoRelease => "Pseudo-Release",
AlbumStatus::Withdrawn => "Withdrawn",
AlbumStatus::Cancelled => "Cancelled",
},
None => "",
}
}
pub fn display_album_type(
primary: &Option<AlbumPrimaryType>,
secondary: &Vec<AlbumSecondaryType>,
@ -237,35 +223,6 @@ mod tests {
assert_eq!(UiDisplay::display_date(&date, &AlbumSeq(5)), "1990 (5)");
}
#[test]
fn display_album_status() {
assert_eq!(
UiDisplay::display_album_status(&Some(AlbumStatus::Official)),
"Official"
);
assert_eq!(
UiDisplay::display_album_status(&Some(AlbumStatus::Promotion)),
"Promotion"
);
assert_eq!(
UiDisplay::display_album_status(&Some(AlbumStatus::Bootleg)),
"Bootleg"
);
assert_eq!(
UiDisplay::display_album_status(&Some(AlbumStatus::PseudoRelease)),
"Pseudo-Release"
);
assert_eq!(
UiDisplay::display_album_status(&Some(AlbumStatus::Withdrawn)),
"Withdrawn"
);
assert_eq!(
UiDisplay::display_album_status(&Some(AlbumStatus::Cancelled)),
"Cancelled"
);
assert_eq!(UiDisplay::display_album_status(&None), "");
}
#[test]
fn display_album_primary_type() {
assert_eq!(

View File

@ -199,7 +199,7 @@ impl IUi for Ui {
#[cfg(test)]
mod tests {
use musichoard::collection::{
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType},
artist::{Artist, ArtistId, ArtistMeta},
};
@ -361,7 +361,6 @@ mod tests {
AlbumMeta::new(id)
.with_date(AlbumDate::new(Some(1990), Some(5), None))
.with_info(AlbumInfo::new(
Some(AlbumStatus::Official),
Some(AlbumPrimaryType::Album),
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
))

View File

@ -4,7 +4,7 @@ use std::collections::HashMap;
use musichoard::collection::{
album::{
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType,
AlbumSecondaryType, AlbumSeq, AlbumStatus,
AlbumSecondaryType, AlbumSeq,
},
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
musicbrainz::MbArtistRef,
@ -47,7 +47,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 2011.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -241,7 +240,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 2004.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Ep),
secondary_types: vec![],
},
@ -325,7 +323,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 2008.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -497,7 +494,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 2001.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -681,7 +677,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 2011.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -798,7 +793,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 1984.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![],
},
@ -904,7 +898,6 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
date: 1999.into(),
seq: AlbumSeq(0),
info: AlbumInfo {
status: Some(AlbumStatus::Official),
primary_type: Some(AlbumPrimaryType::Album),
secondary_types: vec![AlbumSecondaryType::Live],
},