fix
This commit is contained in:
parent
334790da70
commit
0554040341
1 changed files with 2 additions and 11 deletions
|
@ -198,17 +198,8 @@ 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> {
|
||||
let latest_events = Event::get_latest_events_of(u).await;
|
||||
let mut ids = HashSet::new();
|
||||
|
||||
for event in latest_events {
|
||||
if !ids.contains(&event.track) {
|
||||
ids.insert(event.track.clone());
|
||||
}
|
||||
}
|
||||
|
||||
sqlx::query_as("SELECT * FROM track WHERE id = ANY($1)")
|
||||
.bind(ids.into_iter().collect::<Vec<_>>())
|
||||
sqlx::query_as("SELECT DISTINCT t.* FROM track t JOIN events e ON t.id = e.track WHERE e.user = $1 ORDER BY e.time DESC")
|
||||
.bind(&u.username)
|
||||
.fetch_all(get_pg!())
|
||||
.await
|
||||
.unwrap()
|
||||
|
|
Loading…
Reference in a new issue