feat: convert music detail to dxrating
This commit is contained in:
@@ -18,10 +18,10 @@ use sdgb_api::{
|
||||
MaiVersionExt, Sdgb1_50,
|
||||
methods::APIMethod,
|
||||
model::{
|
||||
DataVersion, DxCalculatedEntries, DxRatingNet, GetUserDataApi, GetUserDataApiResp,
|
||||
GetUserMusicApi, GetUserMusicApiResp, GetUserPreviewApi, GetUserPreviewApiResp,
|
||||
GetUserRatingApi, GetUserRatingApiResp, Ping, PingResp, UserLogoutApi,
|
||||
UserLogoutApiResp,
|
||||
DataVersion, DxCalculatedEntries, DxMusicRecord, DxRatingNet, GetUserDataApi,
|
||||
GetUserDataApiResp, GetUserMusicApi, GetUserMusicApiResp, GetUserPreviewApi,
|
||||
GetUserPreviewApiResp, GetUserRatingApi, GetUserRatingApiResp, Ping, PingResp,
|
||||
UserLogoutApi, UserLogoutApiResp,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -80,7 +80,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
|
||||
// TODO: refactor via enum_dispatch
|
||||
match command {
|
||||
Commands::MusicDetail { user_id } => {
|
||||
Commands::MusicDetail { user_id, format } => {
|
||||
let mut music_detail = Vec::new();
|
||||
let mut index = None;
|
||||
|
||||
@@ -111,13 +111,31 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
index = Some(next_index);
|
||||
}
|
||||
|
||||
if human_readable {
|
||||
for detail in music_detail {
|
||||
println!("{detail}");
|
||||
println!("----------");
|
||||
match (human_readable, format) {
|
||||
(true, _) => {
|
||||
for detail in music_detail {
|
||||
println!("{detail}");
|
||||
println!("----------");
|
||||
}
|
||||
}
|
||||
(false, RatingFormat::Origin) => json_display(music_detail)?,
|
||||
(false, RatingFormat::DxRatingNet) => {
|
||||
let dx_export = Vec::from_iter(
|
||||
music_detail
|
||||
.iter()
|
||||
.map(|music| {
|
||||
DxMusicRecord::try_from(music).inspect_err(|e| {
|
||||
warn!("failed to process {}: {e}", music.music_id)
|
||||
})
|
||||
})
|
||||
.flatten(),
|
||||
);
|
||||
json_display(dx_export)?;
|
||||
}
|
||||
(_, format) => {
|
||||
error!("{format:?} was not supported yet");
|
||||
json_display(())?;
|
||||
}
|
||||
} else {
|
||||
json_display(music_detail)?;
|
||||
}
|
||||
}
|
||||
Commands::Rating { user_id, format } => {
|
||||
|
||||
Reference in New Issue
Block a user