This commit is contained in:
JMARyA 2024-10-07 15:36:08 +02:00
parent 43abe4300f
commit 70d45e42a8
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -198,7 +198,8 @@ 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> {
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") // 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")
.bind(&u.username) .bind(&u.username)
.fetch_all(get_pg!()) .fetch_all(get_pg!())
.await .await