playlists

This commit is contained in:
JMARyA 2024-08-17 00:24:45 +02:00
parent edac4b1394
commit f7dbb14a6b
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 21 additions and 8 deletions

View file

@ -278,11 +278,21 @@ impl Libary {
.await
.unwrap()
{
if Track::find_partial(doc! { "artist_id": artist.reference()}, json!({}), None, None)
if Track::find_partial(
doc! { "artist_id": artist.reference()},
json!({}),
None,
None,
)
.await
.unwrap()
.is_empty()
&& Album::find_partial(doc! { "artist_id": artist.reference()}, json!({}), None, None)
&& Album::find_partial(
doc! { "artist_id": artist.reference()},
json!({}),
None,
None,
)
.await
.unwrap()
.is_empty()

View file

@ -90,7 +90,7 @@ impl Track {
"album_id": None::<String>
},
None,
None
None,
)
.await
.unwrap()

View file

@ -24,7 +24,7 @@ pub async fn get_singles_route(u: User) -> FallibleApiResponse {
let singles = Track::find(
doc! { "album_id": None::<String>, "artist_id": {"$ne": None::<String> }},
None,
None
None,
)
.await
.unwrap();

View file

@ -19,7 +19,10 @@ use super::ToAPI;
#[get("/playlists")]
pub async fn playlists_route(u: User) -> FallibleApiResponse {
let mut playlists = vec![json!({"id": "recent", "name": "Recently Played"})];
let mut playlists = vec![
json!({"id": "recent", "name": "Recently Played"}),
json!({"id": "recentlyAdded", "name": "Recently Added"}),
];
let own_playlists = Playlist::find(doc! { "owner": u.reference()}, None, None)
.await