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.
|
||||
pub async fn get_latest_of_user(u: &User) -> Vec<Self> {
|
||||
// todo : weird
|
||||
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")
|
||||
let ids: Vec<(uuid::Uuid,)> = sqlx::query_as(
|
||||
"SELECT DISTINCT(track) FROM events WHERE \"user\" = $1 ORDER BY time DESC LIMIT 300",
|
||||
)
|
||||
.bind(&u.username)
|
||||
.fetch_all(get_pg!())
|
||||
.await
|
||||
.unwrap();
|
||||
res.into_iter()
|
||||
.map(|x| Self {
|
||||
id: x.0,
|
||||
path: x.1,
|
||||
title: x.2,
|
||||
date_added: x.3,
|
||||
album: x.4,
|
||||
artist: x.5,
|
||||
meta: x.6,
|
||||
})
|
||||
.collect()
|
||||
.fetch_all(get_pg!())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut tracks: Vec<_> = Vec::with_capacity(300);
|
||||
|
||||
for track in ids {
|
||||
tracks.push(Track::get(&track.0).await.unwrap());
|
||||
}
|
||||
|
||||
tracks
|
||||
}
|
||||
|
||||
/// Transcodes audio to OPUS format with the specified bitrate.
|
||||
|
|
Loading…
Reference in a new issue