fix
This commit is contained in:
parent
d309c5d8c1
commit
39e2897f0b
1 changed files with 14 additions and 16 deletions
|
@ -198,23 +198,21 @@ impl Track {
|
||||||
///
|
///
|
||||||
/// A vector of `Track` objects representing the latest tracks for the given user.
|
/// A vector of `Track` objects representing the latest tracks for the given user.
|
||||||
pub async fn get_latest_of_user(u: &User) -> Vec<Self> {
|
pub async fn get_latest_of_user(u: &User) -> Vec<Self> {
|
||||||
// todo : weird
|
let ids: Vec<(uuid::Uuid,)> = sqlx::query_as(
|
||||||
let res: Vec<(uuid::Uuid, String, String, chrono::DateTime<chrono::Utc>, Option<uuid::Uuid>, Option<uuid::Uuid>, Option<serde_json::Value>, chrono::DateTime<chrono::Utc>)> = sqlx::query_as("SELECT DISTINCT(t.*), e.time FROM track t JOIN events e ON t.id = e.track WHERE e.user = $1 ORDER BY e.time DESC LIMIT 300")
|
"SELECT DISTINCT(track) FROM events WHERE \"user\" = $1 ORDER BY time DESC LIMIT 300",
|
||||||
|
)
|
||||||
.bind(&u.username)
|
.bind(&u.username)
|
||||||
.fetch_all(get_pg!())
|
.fetch_all(get_pg!())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
res.into_iter()
|
|
||||||
.map(|x| Self {
|
let mut tracks: Vec<_> = Vec::with_capacity(300);
|
||||||
id: x.0,
|
|
||||||
path: x.1,
|
for track in ids {
|
||||||
title: x.2,
|
tracks.push(Track::get(&track.0).await.unwrap());
|
||||||
date_added: x.3,
|
}
|
||||||
album: x.4,
|
|
||||||
artist: x.5,
|
tracks
|
||||||
meta: x.6,
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transcodes audio to OPUS format with the specified bitrate.
|
/// Transcodes audio to OPUS format with the specified bitrate.
|
||||||
|
|
Loading…
Reference in a new issue