update
This commit is contained in:
parent
05d3848602
commit
a1b597ef68
4 changed files with 60 additions and 25 deletions
|
@ -1,10 +1,12 @@
|
|||
use super::api_error;
|
||||
use super::FallibleApiResponse;
|
||||
use mongod::Model;
|
||||
use mongodb::bson::doc;
|
||||
use rocket::{get, State};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::check_admin;
|
||||
use crate::library::track::Track;
|
||||
use crate::library::user::User;
|
||||
use crate::library::Libary;
|
||||
|
||||
|
@ -14,3 +16,19 @@ pub async fn clean_library(lib: &State<Libary>, u: User) -> FallibleApiResponse
|
|||
lib.clean_lost_files().await;
|
||||
Ok(json!({"ok": 1}))
|
||||
}
|
||||
|
||||
#[get("/library/singles")]
|
||||
pub async fn get_singles_route(u: User) -> FallibleApiResponse {
|
||||
check_admin!(u);
|
||||
let singles = Track::find(doc! { "album_id": None::<String>}, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Ok(json!(singles))
|
||||
}
|
||||
|
||||
#[get("/library/orphans")]
|
||||
pub async fn get_orphans_route(u: User) -> FallibleApiResponse {
|
||||
check_admin!(u);
|
||||
let orphans = Track::get_orphans().await;
|
||||
Ok(json!(orphans))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue