Merge pull request 'Fix Album Artists Displayed Wrong' (#165) from 164-album-artists-displayed-wrong into main
Reviewed-on: LibreTunes/LibreTunes#165 Reviewed-by: Ethan Girouard <ethan@girouard.com>
This commit is contained in:
commit
9fb3cd745b
@ -542,24 +542,14 @@ impl Album {
|
|||||||
pub fn get_album_data(album_id: i32, conn: &mut PgPooledConn) -> Result<AlbumData, Box<dyn Error>> {
|
pub fn get_album_data(album_id: i32, conn: &mut PgPooledConn) -> Result<AlbumData, Box<dyn Error>> {
|
||||||
use crate::schema::*;
|
use crate::schema::*;
|
||||||
|
|
||||||
let album: Vec<(Album, std::option::Option<Artist>)> = albums::table
|
let artist_list: Vec<Artist> = album_artists::table
|
||||||
.find(album_id)
|
.filter(album_artists::album_id.eq(album_id))
|
||||||
.left_join(songs::table.on(albums::id.nullable().eq(songs::album_id)))
|
.inner_join(artists::table.on(album_artists::artist_id.eq(artists::id)))
|
||||||
.left_join(song_artists::table.inner_join(artists::table).on(songs::id.eq(song_artists::song_id)))
|
.select(
|
||||||
.select((
|
artists::all_columns
|
||||||
albums::all_columns,
|
)
|
||||||
artists::all_columns.nullable()
|
|
||||||
))
|
|
||||||
.distinct()
|
|
||||||
.load(conn)?;
|
.load(conn)?;
|
||||||
|
|
||||||
let mut artist_list: Vec<Artist> = Vec::new();
|
|
||||||
|
|
||||||
for (_, artist) in album {
|
|
||||||
if let Some(artist) = artist {
|
|
||||||
artist_list.push(artist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Get info of album
|
// Get info of album
|
||||||
let albuminfo = albums::table
|
let albuminfo = albums::table
|
||||||
.filter(albums::id.eq(album_id))
|
.filter(albums::id.eq(album_id))
|
||||||
@ -671,7 +661,7 @@ impl Album {
|
|||||||
|
|
||||||
// Sort the songs by date
|
// Sort the songs by date
|
||||||
let mut songdata: Vec<SongData> = album_songs.into_values().collect();
|
let mut songdata: Vec<SongData> = album_songs.into_values().collect();
|
||||||
songdata.sort_by(|a, b| b.track.cmp(&a.track));
|
songdata.sort_by(|a, b| a.track.cmp(&b.track));
|
||||||
Ok(songdata)
|
Ok(songdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user