This commit is contained in:
JMARyA 2024-08-16 12:24:02 +02:00
parent 05d3848602
commit a1b597ef68
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 60 additions and 25 deletions

View file

@ -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))
}