update
This commit is contained in:
parent
636ad0bf34
commit
edac4b1394
8 changed files with 61 additions and 18 deletions
|
@ -24,6 +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
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
@ -21,7 +21,7 @@ use super::ToAPI;
|
|||
pub async fn playlists_route(u: User) -> FallibleApiResponse {
|
||||
let mut playlists = vec![json!({"id": "recent", "name": "Recently Played"})];
|
||||
|
||||
let own_playlists = Playlist::find(doc! { "owner": u.reference()}, None)
|
||||
let own_playlists = Playlist::find(doc! { "owner": u.reference()}, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
@ -35,10 +35,37 @@ pub async fn playlists_route(u: User) -> FallibleApiResponse {
|
|||
Ok(json!(playlists))
|
||||
}
|
||||
|
||||
pub async fn recently_added_playlist() -> FallibleApiResponse {
|
||||
let tracks = Track::find(doc! {}, Some(90), Some(doc! { "added": 1 }))
|
||||
.await
|
||||
.unwrap();
|
||||
Ok(json!(to_api(&tracks).await))
|
||||
}
|
||||
|
||||
#[get("/playlist/<id>")]
|
||||
pub async fn playlist_route(id: &str, u: User) -> FallibleApiResponse {
|
||||
if id == "recents" {
|
||||
// todo : recently played
|
||||
return Ok(Playlist {
|
||||
_id: "recents".to_string(),
|
||||
owner: u.reference(),
|
||||
title: "Recently Played".to_string(),
|
||||
visibility: Visibility::Public,
|
||||
tracks: vec![],
|
||||
}
|
||||
.api()
|
||||
.await);
|
||||
}
|
||||
|
||||
if id == "recentlyAdded" {
|
||||
return Ok(Playlist {
|
||||
_id: "recentlyAdded".to_string(),
|
||||
owner: u.reference(),
|
||||
title: "Recently Added".to_string(),
|
||||
visibility: Visibility::Public,
|
||||
tracks: vec![],
|
||||
}
|
||||
.api()
|
||||
.await);
|
||||
}
|
||||
|
||||
let playlist = Playlist::get(id)
|
||||
|
@ -60,6 +87,10 @@ pub async fn playlist_tracks_route(id: &str, u: User) -> FallibleApiResponse {
|
|||
// todo : recently played
|
||||
}
|
||||
|
||||
if id == "recentlyAdded" {
|
||||
return recently_added_playlist().await;
|
||||
}
|
||||
|
||||
let playlist = Playlist::get(id)
|
||||
.await
|
||||
.ok_or_else(|| api_error("No playlist with that ID found"))?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue