@@ -32,6 +32,36 @@ pub struct AlbumFragment {
3232 pub discs : Vec < DiscFragment > ,
3333}
3434
35+ impl AlbumFragment {
36+ pub fn release_date ( & self ) -> crate :: model:: AnniDate {
37+ crate :: model:: AnniDate :: new (
38+ self . year as u16 ,
39+ self . month . unwrap_or ( 0 ) as u8 ,
40+ self . day . unwrap_or ( 0 ) as u8 ,
41+ )
42+ }
43+ }
44+
45+ impl From < AlbumFragment > for crate :: model:: Album {
46+ fn from ( album : AlbumFragment ) -> Self {
47+ let release_date = album. release_date ( ) ;
48+ crate :: model:: Album :: new (
49+ crate :: model:: AlbumInfo {
50+ album_id : album. album_id ,
51+ title : album. title ,
52+ edition : album. edition ,
53+ artist : album. artist ,
54+ artists : None ,
55+ release_date,
56+ album_type : crate :: model:: TrackType :: Normal ,
57+ catalog : album. catalog . unwrap_or_default ( ) ,
58+ tags : album. tags . into_iter ( ) . map ( Into :: into) . collect ( ) ,
59+ } ,
60+ album. discs . into_iter ( ) . map ( Into :: into) . collect ( ) ,
61+ )
62+ }
63+ }
64+
3565#[ derive( cynic:: QueryFragment , Debug ) ]
3666#[ cynic( graphql_type = "Disc" ) ]
3767pub struct DiscFragment {
@@ -46,6 +76,22 @@ pub struct DiscFragment {
4676 pub tracks : Vec < TrackFragment > ,
4777}
4878
79+ impl From < DiscFragment > for crate :: model:: Disc {
80+ fn from ( disc : DiscFragment ) -> Self {
81+ crate :: model:: Disc :: new (
82+ crate :: model:: DiscInfo {
83+ title : disc. title ,
84+ catalog : disc. catalog . unwrap_or_default ( ) ,
85+ artist : disc. artist ,
86+ artists : None ,
87+ disc_type : None ,
88+ tags : disc. tags . into_iter ( ) . map ( Into :: into) . collect ( ) ,
89+ } ,
90+ disc. tracks . into_iter ( ) . map ( Into :: into) . collect ( ) ,
91+ )
92+ }
93+ }
94+
4995#[ derive( cynic:: QueryFragment , Debug ) ]
5096#[ cynic( graphql_type = "Track" ) ]
5197pub struct TrackFragment {
@@ -61,6 +107,18 @@ pub struct TrackFragment {
61107 pub updated_at : DateTime ,
62108}
63109
110+ impl From < TrackFragment > for crate :: model:: Track {
111+ fn from ( track : TrackFragment ) -> Self {
112+ crate :: model:: Track {
113+ title : track. title ,
114+ artist : Some ( track. artist ) ,
115+ artists : None , // TODO: parse artists
116+ track_type : Some ( track. type_ . into ( ) ) ,
117+ tags : track. tags . into_iter ( ) . map ( Into :: into) . collect ( ) ,
118+ }
119+ }
120+ }
121+
64122#[ derive( cynic:: QueryFragment , Debug ) ]
65123#[ cynic( graphql_type = "Tag" ) ]
66124pub struct TagBase {
@@ -72,6 +130,12 @@ pub struct TagBase {
72130 pub updated_at : DateTime ,
73131}
74132
133+ impl From < TagBase > for crate :: model:: TagString {
134+ fn from ( value : TagBase ) -> Self {
135+ crate :: model:: TagString :: new ( value. name , value. type_ . into ( ) )
136+ }
137+ }
138+
75139#[ derive( cynic:: Enum , Clone , Copy , Debug ) ]
76140pub enum MetadataOrganizeLevel {
77141 Initial ,
@@ -107,6 +171,23 @@ pub enum TagTypeInput {
107171 Others ,
108172}
109173
174+ impl From < TagTypeInput > for crate :: model:: TagType {
175+ fn from ( value : TagTypeInput ) -> Self {
176+ match value {
177+ TagTypeInput :: Artist => crate :: model:: TagType :: Artist ,
178+ TagTypeInput :: Group => crate :: model:: TagType :: Group ,
179+ TagTypeInput :: Animation => crate :: model:: TagType :: Animation ,
180+ TagTypeInput :: Radio => crate :: model:: TagType :: Radio ,
181+ TagTypeInput :: Series => crate :: model:: TagType :: Series ,
182+ TagTypeInput :: Project => crate :: model:: TagType :: Project ,
183+ TagTypeInput :: Game => crate :: model:: TagType :: Game ,
184+ TagTypeInput :: Organization => crate :: model:: TagType :: Organization ,
185+ TagTypeInput :: Category => crate :: model:: TagType :: Category ,
186+ TagTypeInput :: Others => crate :: model:: TagType :: Unknown ,
187+ }
188+ }
189+ }
190+
110191impl From < & crate :: model:: TrackType > for TrackTypeInput {
111192 fn from ( value : & crate :: model:: TrackType ) -> Self {
112193 match value {
@@ -119,3 +200,9 @@ impl From<&crate::model::TrackType> for TrackTypeInput {
119200 }
120201 }
121202}
203+
204+ impl From < TrackTypeInput > for crate :: model:: TrackType {
205+ fn from ( value : TrackTypeInput ) -> Self {
206+ value. into ( )
207+ }
208+ }
0 commit comments