Add status to database
This commit is contained in:
parent
6d1e8b88f4
commit
3fb3f304ff
@ -294,6 +294,7 @@ impl Merge for AlbumMeta {
|
|||||||
|
|
||||||
impl Merge for AlbumInfo {
|
impl Merge for AlbumInfo {
|
||||||
fn merge_in_place(&mut self, other: Self) {
|
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);
|
self.primary_type = self.primary_type.take().or(other.primary_type);
|
||||||
if self.secondary_types.is_empty() {
|
if self.secondary_types.is_empty() {
|
||||||
self.secondary_types = other.secondary_types;
|
self.secondary_types = other.secondary_types;
|
||||||
|
@ -14,13 +14,13 @@ pub static DATABASE_JSON: &str = "{\
|
|||||||
\"title\":\"album_title a.a\",\"lib_id\":{\"Value\":1},\
|
\"title\":\"album_title a.a\",\"lib_id\":{\"Value\":1},\
|
||||||
\"date\":{\"year\":1998,\"month\":null,\"day\":null},\"seq\":1,\
|
\"date\":{\"year\":1998,\"month\":null,\"day\":null},\"seq\":1,\
|
||||||
\"musicbrainz\":{\"Some\":\"00000000-0000-0000-0000-000000000000\"},\
|
\"musicbrainz\":{\"Some\":\"00000000-0000-0000-0000-000000000000\"},\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
},\
|
},\
|
||||||
{\
|
{\
|
||||||
\"title\":\"album_title a.b\",\"lib_id\":{\"Value\":2},\
|
\"title\":\"album_title a.b\",\"lib_id\":{\"Value\":2},\
|
||||||
\"date\":{\"year\":2015,\"month\":4,\"day\":null},\"seq\":1,\
|
\"date\":{\"year\":2015,\"month\":4,\"day\":null},\"seq\":1,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
}\
|
}\
|
||||||
]\
|
]\
|
||||||
},\
|
},\
|
||||||
@ -41,25 +41,25 @@ pub static DATABASE_JSON: &str = "{\
|
|||||||
\"title\":\"album_title b.a\",\"lib_id\":{\"Value\":3},\
|
\"title\":\"album_title b.a\",\"lib_id\":{\"Value\":3},\
|
||||||
\"date\":{\"year\":2003,\"month\":6,\"day\":6},\"seq\":1,\
|
\"date\":{\"year\":2003,\"month\":6,\"day\":6},\"seq\":1,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
},\
|
},\
|
||||||
{\
|
{\
|
||||||
\"title\":\"album_title b.b\",\"lib_id\":{\"Value\":4},\
|
\"title\":\"album_title b.b\",\"lib_id\":{\"Value\":4},\
|
||||||
\"date\":{\"year\":2008,\"month\":null,\"day\":null},\"seq\":3,\
|
\"date\":{\"year\":2008,\"month\":null,\"day\":null},\"seq\":3,\
|
||||||
\"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111111\"},\
|
\"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111111\"},\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
},\
|
},\
|
||||||
{\
|
{\
|
||||||
\"title\":\"album_title b.c\",\"lib_id\":{\"Value\":5},\
|
\"title\":\"album_title b.c\",\"lib_id\":{\"Value\":5},\
|
||||||
\"date\":{\"year\":2009,\"month\":null,\"day\":null},\"seq\":2,\
|
\"date\":{\"year\":2009,\"month\":null,\"day\":null},\"seq\":2,\
|
||||||
\"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111112\"},\
|
\"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111112\"},\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
},\
|
},\
|
||||||
{\
|
{\
|
||||||
\"title\":\"album_title b.d\",\"lib_id\":{\"Value\":6},\
|
\"title\":\"album_title b.d\",\"lib_id\":{\"Value\":6},\
|
||||||
\"date\":{\"year\":2015,\"month\":null,\"day\":null},\"seq\":4,\
|
\"date\":{\"year\":2015,\"month\":null,\"day\":null},\"seq\":4,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
}\
|
}\
|
||||||
]\
|
]\
|
||||||
},\
|
},\
|
||||||
@ -73,13 +73,13 @@ pub static DATABASE_JSON: &str = "{\
|
|||||||
\"title\":\"album_title c.a\",\"lib_id\":{\"Value\":7},\
|
\"title\":\"album_title c.a\",\"lib_id\":{\"Value\":7},\
|
||||||
\"date\":{\"year\":1985,\"month\":null,\"day\":null},\"seq\":0,\
|
\"date\":{\"year\":1985,\"month\":null,\"day\":null},\"seq\":0,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
},\
|
},\
|
||||||
{\
|
{\
|
||||||
\"title\":\"album_title c.b\",\"lib_id\":{\"Value\":8},\
|
\"title\":\"album_title c.b\",\"lib_id\":{\"Value\":8},\
|
||||||
\"date\":{\"year\":2018,\"month\":null,\"day\":null},\"seq\":0,\
|
\"date\":{\"year\":2018,\"month\":null,\"day\":null},\"seq\":0,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
}\
|
}\
|
||||||
]\
|
]\
|
||||||
},\
|
},\
|
||||||
@ -93,13 +93,13 @@ pub static DATABASE_JSON: &str = "{\
|
|||||||
\"title\":\"album_title d.a\",\"lib_id\":{\"Value\":9},\
|
\"title\":\"album_title d.a\",\"lib_id\":{\"Value\":9},\
|
||||||
\"date\":{\"year\":1995,\"month\":null,\"day\":null},\"seq\":0,\
|
\"date\":{\"year\":1995,\"month\":null,\"day\":null},\"seq\":0,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
},\
|
},\
|
||||||
{\
|
{\
|
||||||
\"title\":\"album_title d.b\",\"lib_id\":{\"Value\":10},\
|
\"title\":\"album_title d.b\",\"lib_id\":{\"Value\":10},\
|
||||||
\"date\":{\"year\":2028,\"month\":null,\"day\":null},\"seq\":0,\
|
\"date\":{\"year\":2028,\"month\":null,\"day\":null},\"seq\":0,\
|
||||||
\"musicbrainz\":\"None\",\
|
\"musicbrainz\":\"None\",\
|
||||||
\"primary_type\":\"Album\",\"secondary_types\":[]\
|
\"status\":\"Official\",\"primary_type\":\"Album\",\"secondary_types\":[]\
|
||||||
}\
|
}\
|
||||||
]\
|
]\
|
||||||
}\
|
}\
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::core::collection::{
|
use crate::core::collection::{
|
||||||
album::{AlbumDate, AlbumLibId, AlbumPrimaryType, AlbumSecondaryType},
|
album::{AlbumDate, AlbumLibId, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
||||||
musicbrainz::MbRefOption,
|
musicbrainz::MbRefOption,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,6 +59,32 @@ pub enum MbRefOptionDef<T> {
|
|||||||
None,
|
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)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(remote = "AlbumPrimaryType")]
|
#[serde(remote = "AlbumPrimaryType")]
|
||||||
pub enum AlbumPrimaryTypeDef {
|
pub enum AlbumPrimaryTypeDef {
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
external::database::serde::common::{
|
external::database::serde::common::{
|
||||||
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
||||||
SerdeAlbumSecondaryType,
|
SerdeAlbumSecondaryType, SerdeAlbumStatus,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ pub struct DeserializeAlbum {
|
|||||||
date: SerdeAlbumDate,
|
date: SerdeAlbumDate,
|
||||||
seq: u8,
|
seq: u8,
|
||||||
musicbrainz: DeserializeMbRefOption,
|
musicbrainz: DeserializeMbRefOption,
|
||||||
|
status: Option<SerdeAlbumStatus>,
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
@ -138,7 +139,7 @@ impl From<DeserializeAlbum> for Album {
|
|||||||
date: album.date.into(),
|
date: album.date.into(),
|
||||||
seq: AlbumSeq(album.seq),
|
seq: AlbumSeq(album.seq),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
status: None,
|
status: album.status.map(Into::into),
|
||||||
primary_type: album.primary_type.map(Into::into),
|
primary_type: album.primary_type.map(Into::into),
|
||||||
secondary_types: album.secondary_types.into_iter().map(Into::into).collect(),
|
secondary_types: album.secondary_types.into_iter().map(Into::into).collect(),
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
|
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
|
||||||
external::database::serde::common::{
|
external::database::serde::common::{
|
||||||
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
||||||
SerdeAlbumSecondaryType,
|
SerdeAlbumSecondaryType, SerdeAlbumStatus,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ pub struct SerializeAlbum<'a> {
|
|||||||
date: SerdeAlbumDate,
|
date: SerdeAlbumDate,
|
||||||
seq: u8,
|
seq: u8,
|
||||||
musicbrainz: SerializeMbRefOption<'a>,
|
musicbrainz: SerializeMbRefOption<'a>,
|
||||||
|
status: Option<SerdeAlbumStatus>,
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
@ -97,6 +98,7 @@ impl<'a> From<&'a Album> for SerializeAlbum<'a> {
|
|||||||
date: album.meta.date.into(),
|
date: album.meta.date.into(),
|
||||||
seq: album.meta.seq.0,
|
seq: album.meta.seq.0,
|
||||||
musicbrainz: (&album.meta.id.mb_ref).into(),
|
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),
|
primary_type: album.meta.info.primary_type.map(Into::into),
|
||||||
secondary_types: album
|
secondary_types: album
|
||||||
.meta
|
.meta
|
||||||
|
@ -1 +1 @@
|
|||||||
{"V20250103":[{"name":"Аркона","sort":"Arkona","musicbrainz":{"Some":"baad262d-55ef-427a-83c7-f7530964f212"},"properties":{"Bandcamp":["https://arkonamoscow.bandcamp.com/"],"MusicButler":["https://www.musicbutler.io/artist-page/283448581"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/arkona/download-streaming-albums"]},"albums":[{"title":"Slovo","lib_id":{"Value":7},"date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Eluveitie","sort":null,"musicbrainz":{"Some":"8000598a-5edb-401c-8e6d-36b167feaf38"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/269358403"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/eluveitie/download-streaming-albums"]},"albums":[{"title":"Vên [re‐recorded]","lib_id":{"Value":1},"date":{"year":2004,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Ep","secondary_types":[]},{"title":"Slania","lib_id":{"Value":2},"date":{"year":2008,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Frontside","sort":null,"musicbrainz":{"Some":"3a901353-fccd-4afd-ad01-9c03f451b490"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/826588800"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/frontside/download-streaming-albums"]},"albums":[{"title":"…nasze jest królestwo, potęga i chwała na wieki…","lib_id":{"Value":3},"date":{"year":2001,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Heaven’s Basement","sort":"Heaven’s Basement","musicbrainz":{"Some":"c2c4d56a-d599-4a18-bd2f-ae644e2198cc"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/291158685"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/heaven-s-basement/download-streaming-albums"]},"albums":[{"title":"Paper Plague","lib_id":"Singleton","date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":null,"secondary_types":[]},{"title":"Unbreakable","lib_id":{"Value":4},"date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Metallica","sort":null,"musicbrainz":{"Some":"65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/3996865"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/metallica/download-streaming-albums"]},"albums":[{"title":"Ride the Lightning","lib_id":{"Value":5},"date":{"year":1984,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]},{"title":"S&M","lib_id":{"Value":6},"date":{"year":1999,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":["Live"]}]}]}
|
{"V20250103":[{"name":"Аркона","sort":"Arkona","musicbrainz":{"Some":"baad262d-55ef-427a-83c7-f7530964f212"},"properties":{"Bandcamp":["https://arkonamoscow.bandcamp.com/"],"MusicButler":["https://www.musicbutler.io/artist-page/283448581"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/arkona/download-streaming-albums"]},"albums":[{"title":"Slovo","lib_id":{"Value":7},"date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Album","secondary_types":[]}]},{"name":"Eluveitie","sort":null,"musicbrainz":{"Some":"8000598a-5edb-401c-8e6d-36b167feaf38"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/269358403"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/eluveitie/download-streaming-albums"]},"albums":[{"title":"Vên [re‐recorded]","lib_id":{"Value":1},"date":{"year":2004,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Ep","secondary_types":[]},{"title":"Slania","lib_id":{"Value":2},"date":{"year":2008,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Album","secondary_types":[]}]},{"name":"Frontside","sort":null,"musicbrainz":{"Some":"3a901353-fccd-4afd-ad01-9c03f451b490"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/826588800"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/frontside/download-streaming-albums"]},"albums":[{"title":"…nasze jest królestwo, potęga i chwała na wieki…","lib_id":{"Value":3},"date":{"year":2001,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Album","secondary_types":[]}]},{"name":"Heaven’s Basement","sort":"Heaven’s Basement","musicbrainz":{"Some":"c2c4d56a-d599-4a18-bd2f-ae644e2198cc"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/291158685"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/heaven-s-basement/download-streaming-albums"]},"albums":[{"title":"Paper Plague","lib_id":"Singleton","date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":null,"primary_type":null,"secondary_types":[]},{"title":"Unbreakable","lib_id":{"Value":4},"date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Album","secondary_types":[]}]},{"name":"Metallica","sort":null,"musicbrainz":{"Some":"65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/3996865"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/metallica/download-streaming-albums"]},"albums":[{"title":"Ride the Lightning","lib_id":{"Value":5},"date":{"year":1984,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Album","secondary_types":[]},{"title":"S&M","lib_id":{"Value":6},"date":{"year":1999,"month":null,"day":null},"seq":0,"musicbrainz":"None","status":"Official","primary_type":"Album","secondary_types":["Live"]}]}]}
|
Loading…
x
Reference in New Issue
Block a user