From 397027192214d8e5451eae40e2a0e9d84ff5b471 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Fri, 3 Jan 2025 20:21:45 +0100 Subject: [PATCH] Remove album status from all types --- src/core/collection/album.rs | 21 ---------- src/core/musichoard/database.rs | 3 +- src/core/testmod.rs | 1 - src/external/database/serde/common.rs | 28 +------------ src/external/database/serde/deserialize.rs | 4 +- src/external/database/serde/serialize.rs | 4 +- src/external/musicbrainz/api/mod.rs | 25 +----------- src/testmod/full.rs | 10 ----- src/tui/app/machine/match_state.rs | 3 +- src/tui/lib/external/musicbrainz/api/mod.rs | 1 - src/tui/testmod.rs | 1 - src/tui/ui/browse_state.rs | 4 -- src/tui/ui/display.rs | 45 +-------------------- src/tui/ui/mod.rs | 3 +- tests/testlib.rs | 9 +---- 15 files changed, 9 insertions(+), 153 deletions(-) diff --git a/src/core/collection/album.rs b/src/core/collection/album.rs index ffcdfb8..308e901 100644 --- a/src/core/collection/album.rs +++ b/src/core/collection/album.rs @@ -27,7 +27,6 @@ pub struct AlbumMeta { /// Album non-identifier metadata. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct AlbumInfo { - pub status: Option, pub primary_type: Option, pub secondary_types: Vec, } @@ -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, primary_type: Option, secondary_types: Vec, ) -> 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; diff --git a/src/core/musichoard/database.rs b/src/core/musichoard/database.rs index 8de11a5..0d387aa 100644 --- a/src/core/musichoard/database.rs +++ b/src/core/musichoard/database.rs @@ -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], ); diff --git a/src/core/testmod.rs b/src/core/testmod.rs index 929723a..a812f67 100644 --- a/src/core/testmod.rs +++ b/src/core/testmod.rs @@ -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}, diff --git a/src/external/database/serde/common.rs b/src/external/database/serde/common.rs index c4c245a..1cc230e 100644 --- a/src/external/database/serde/common.rs +++ b/src/external/database/serde/common.rs @@ -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 { 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 for AlbumStatus { - fn from(value: SerdeAlbumStatus) -> Self { - value.0 - } -} - -impl From for SerdeAlbumStatus { - fn from(value: AlbumStatus) -> Self { - SerdeAlbumStatus(value) - } -} - #[derive(Debug, Deserialize, Serialize)] #[serde(remote = "AlbumPrimaryType")] pub enum AlbumPrimaryTypeDef { diff --git a/src/external/database/serde/deserialize.rs b/src/external/database/serde/deserialize.rs index f73d46c..182c9c6 100644 --- a/src/external/database/serde/deserialize.rs +++ b/src/external/database/serde/deserialize.rs @@ -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, primary_type: Option, secondary_types: Vec, } @@ -139,7 +138,6 @@ impl From 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(), }, diff --git a/src/external/database/serde/serialize.rs b/src/external/database/serde/serialize.rs index a794aa7..a88657f 100644 --- a/src/external/database/serde/serialize.rs +++ b/src/external/database/serde/serialize.rs @@ -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, primary_type: Option, secondary_types: Vec, } @@ -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 diff --git a/src/external/musicbrainz/api/mod.rs b/src/external/musicbrainz/api/mod.rs index 46e01a0..bc3cc60 100644 --- a/src/external/musicbrainz/api/mod.rs +++ b/src/external/musicbrainz/api/mod.rs @@ -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, pub primary_type: Option, pub secondary_types: Option>, } @@ -142,7 +141,6 @@ pub struct SerdeMbReleaseGroupMeta { id: SerdeMbid, title: String, first_release_date: SerdeAlbumDate, - status: Option, primary_type: Option, secondary_types: Option>, } @@ -153,7 +151,6 @@ impl From 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 for AlbumStatus { - fn from(value: SerdeAlbumStatus) -> Self { - value.0 - } -} - #[derive(Debug, Deserialize)] #[serde(remote = "AlbumPrimaryType")] pub enum AlbumPrimaryTypeDef { diff --git a/src/testmod/full.rs b/src/testmod/full.rs index a07a5d0..4e5c1d2 100644 --- a/src/testmod/full.rs +++ b/src/testmod/full.rs @@ -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![], }, diff --git a/src/tui/app/machine/match_state.rs b/src/tui/app/machine/match_state.rs index 241679c..b25e669 100644 --- a/src/tui/app/machine/match_state.rs +++ b/src/tui/app/machine/match_state.rs @@ -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], )) diff --git a/src/tui/lib/external/musicbrainz/api/mod.rs b/src/tui/lib/external/musicbrainz/api/mod.rs index eede4a1..acc1d4f 100644 --- a/src/tui/lib/external/musicbrainz/api/mod.rs +++ b/src/tui/lib/external/musicbrainz/api/mod.rs @@ -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(), }, diff --git a/src/tui/testmod.rs b/src/tui/testmod.rs index f5cb5cf..6346109 100644 --- a/src/tui/testmod.rs +++ b/src/tui/testmod.rs @@ -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}, diff --git a/src/tui/ui/browse_state.rs b/src/tui/ui/browse_state.rs index 7047802..a99e195 100644 --- a/src/tui/ui/browse_state.rs +++ b/src/tui/ui/browse_state.rs @@ -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("") diff --git a/src/tui/ui/display.rs b/src/tui/ui/display.rs index 32535cd..1c91792 100644 --- a/src/tui/ui/display.rs +++ b/src/tui/ui/display.rs @@ -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) -> &'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, secondary: &Vec, @@ -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!( diff --git a/src/tui/ui/mod.rs b/src/tui/ui/mod.rs index 5297b03..c3e3ee3 100644 --- a/src/tui/ui/mod.rs +++ b/src/tui/ui/mod.rs @@ -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], )) diff --git a/tests/testlib.rs b/tests/testlib.rs index 90138c0..119042a 100644 --- a/tests/testlib.rs +++ b/tests/testlib.rs @@ -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> = 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> = 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> = 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> = 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> = 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> = 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> = 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], },