From 3cb9a775e76bb2c47dccc195a5c7032639e0d4a6 Mon Sep 17 00:00:00 2001 From: Nghia Date: Mon, 15 Apr 2024 00:29:36 +0200 Subject: [PATCH] =?UTF-8?q?refactor(music-folder):=20move=20music=20folder?= =?UTF-8?q?=20related=20endpoint=20to=20another=E2=80=A6=20(#96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/folder/list.rs | 4 +++- src/models/music_folders.rs | 4 ++-- src/open_subsonic/browsing/mod.rs | 3 --- src/open_subsonic/mod.rs | 1 + .../{browsing => music_folder}/get_folder_stats.rs | 2 +- src/open_subsonic/music_folder/mod.rs | 10 ++++++++++ types/src/browsing/get_music_folders.rs | 2 +- types/src/browsing/mod.rs | 4 ---- types/src/lib.rs | 1 + .../src/{browsing => music_folder}/get_folder_stats.rs | 0 .../{browsing/music_folder.rs => music_folder/mod.rs} | 2 ++ 11 files changed, 21 insertions(+), 12 deletions(-) rename src/open_subsonic/{browsing => music_folder}/get_folder_stats.rs (98%) create mode 100644 src/open_subsonic/music_folder/mod.rs rename types/src/{browsing => music_folder}/get_folder_stats.rs (100%) rename types/src/{browsing/music_folder.rs => music_folder/mod.rs} (91%) diff --git a/frontend/src/components/folder/list.rs b/frontend/src/components/folder/list.rs index a04a4298b..af13e7d4f 100644 --- a/frontend/src/components/folder/list.rs +++ b/frontend/src/components/folder/list.rs @@ -1,5 +1,7 @@ use dioxus::prelude::*; -use nghe_types::browsing::get_folder_stats::{GetFolderStatsParams, SubsonicGetFolderStatsBody}; +use nghe_types::music_folder::get_folder_stats::{ + GetFolderStatsParams, SubsonicGetFolderStatsBody, +}; use readable::byte::*; use readable::num::*; diff --git a/src/models/music_folders.rs b/src/models/music_folders.rs index dca74bcab..8690b067b 100644 --- a/src/models/music_folders.rs +++ b/src/models/music_folders.rs @@ -7,8 +7,8 @@ use uuid::Uuid; pub use crate::schema::music_folders; -#[add_convert_types(into = nghe_types::browsing::MusicFolder, skips(path))] -#[add_convert_types(into = nghe_types::browsing::MusicFolderPath)] +#[add_convert_types(into = nghe_types::music_folder::MusicFolder, skips(path))] +#[add_convert_types(into = nghe_types::music_folder::MusicFolderPath)] #[derive(Debug, Queryable, Selectable)] #[diesel(table_name = music_folders)] #[diesel(check_for_backend(diesel::pg::Pg))] diff --git a/src/open_subsonic/browsing/mod.rs b/src/open_subsonic/browsing/mod.rs index 7323f1acf..81a7397f2 100644 --- a/src/open_subsonic/browsing/mod.rs +++ b/src/open_subsonic/browsing/mod.rs @@ -3,7 +3,6 @@ mod get_album_info2; mod get_artist; mod get_artist_info2; mod get_artists; -mod get_folder_stats; mod get_genres; mod get_indexes; mod get_music_directory; @@ -43,6 +42,4 @@ pub fn router() -> Router { .route("/rest/getAlbumInfo2.view", get(get_album_info2::get_album_info2_handler)) .route("/rest/getArtistInfo2", get(get_artist_info2::get_artist_info2_handler)) .route("/rest/getArtistInfo2.view", get(get_artist_info2::get_artist_info2_handler)) - .route("/rest/getFolderStats", get(get_folder_stats::get_folder_stats_handler)) - .route("/rest/getFolderStats.view", get(get_folder_stats::get_folder_stats_handler)) } diff --git a/src/open_subsonic/mod.rs b/src/open_subsonic/mod.rs index c337cf9e2..18d785633 100644 --- a/src/open_subsonic/mod.rs +++ b/src/open_subsonic/mod.rs @@ -5,6 +5,7 @@ pub mod extension; pub mod media_annotation; pub mod media_list; pub mod media_retrieval; +pub mod music_folder; pub mod permission; pub mod scan; pub mod searching; diff --git a/src/open_subsonic/browsing/get_folder_stats.rs b/src/open_subsonic/music_folder/get_folder_stats.rs similarity index 98% rename from src/open_subsonic/browsing/get_folder_stats.rs rename to src/open_subsonic/music_folder/get_folder_stats.rs index 7a79cd949..45006ebf8 100644 --- a/src/open_subsonic/browsing/get_folder_stats.rs +++ b/src/open_subsonic/music_folder/get_folder_stats.rs @@ -14,7 +14,7 @@ use crate::{Database, DatabasePool}; add_common_validate!(GetFolderStatsParams, admin); add_axum_response!(GetFolderStatsBody); -#[add_convert_types(into = nghe_types::browsing::get_folder_stats::FolderStats)] +#[add_convert_types(into = nghe_types::music_folder::get_folder_stats::FolderStats)] #[derive(Debug, Queryable)] #[diesel(table_name = music_folders)] #[diesel(check_for_backend(diesel::pg::Pg))] diff --git a/src/open_subsonic/music_folder/mod.rs b/src/open_subsonic/music_folder/mod.rs new file mode 100644 index 000000000..720d140e6 --- /dev/null +++ b/src/open_subsonic/music_folder/mod.rs @@ -0,0 +1,10 @@ +mod get_folder_stats; + +use axum::routing::get; +use axum::Router; + +pub fn router() -> Router { + Router::new() + .route("/rest/getFolderStats", get(get_folder_stats::get_folder_stats_handler)) + .route("/rest/getFolderStats.view", get(get_folder_stats::get_folder_stats_handler)) +} diff --git a/types/src/browsing/get_music_folders.rs b/types/src/browsing/get_music_folders.rs index 4c5f151de..bd610d254 100644 --- a/types/src/browsing/get_music_folders.rs +++ b/types/src/browsing/get_music_folders.rs @@ -2,7 +2,7 @@ use nghe_proc_macros::{ add_common_convert, add_request_types_test, add_subsonic_response, add_types_derive, }; -use super::MusicFolder; +use crate::music_folder::MusicFolder; #[add_common_convert] pub struct GetMusicFoldersParams {} diff --git a/types/src/browsing/mod.rs b/types/src/browsing/mod.rs index 2e7d11442..84ee6b68b 100644 --- a/types/src/browsing/mod.rs +++ b/types/src/browsing/mod.rs @@ -3,13 +3,9 @@ pub mod get_album_info2; pub mod get_artist; pub mod get_artist_info2; pub mod get_artists; -pub mod get_folder_stats; pub mod get_genres; pub mod get_indexes; pub mod get_music_directory; pub mod get_music_folders; pub mod get_song; pub mod get_top_songs; -pub mod music_folder; - -pub use music_folder::{MusicFolder, MusicFolderPath}; diff --git a/types/src/lib.rs b/types/src/lib.rs index 9ef6620fa..8cd4cd582 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -9,6 +9,7 @@ pub mod extension; pub mod media_annotation; pub mod media_list; pub mod media_retrieval; +pub mod music_folder; pub mod permission; pub mod scan; pub mod searching; diff --git a/types/src/browsing/get_folder_stats.rs b/types/src/music_folder/get_folder_stats.rs similarity index 100% rename from types/src/browsing/get_folder_stats.rs rename to types/src/music_folder/get_folder_stats.rs diff --git a/types/src/browsing/music_folder.rs b/types/src/music_folder/mod.rs similarity index 91% rename from types/src/browsing/music_folder.rs rename to types/src/music_folder/mod.rs index 9df69a629..6bd62e53f 100644 --- a/types/src/browsing/music_folder.rs +++ b/types/src/music_folder/mod.rs @@ -1,3 +1,5 @@ +pub mod get_folder_stats; + use nghe_proc_macros::add_types_derive; use uuid::Uuid;