Return album appearances
This commit is contained in:
parent
ae9f94ce4f
commit
7a1d433c8a
3 changed files with 27 additions and 7 deletions
|
@ -304,17 +304,34 @@ impl Index {
|
||||||
|
|
||||||
pub(self) fn get_artist(&self, artist_id: ArtistID) -> Option<collection::Artist> {
|
pub(self) fn get_artist(&self, artist_id: ArtistID) -> Option<collection::Artist> {
|
||||||
self.artists.get(&artist_id).map(|a| {
|
self.artists.get(&artist_id).map(|a| {
|
||||||
let mut albums = a
|
let albums = {
|
||||||
.albums
|
let mut albums = a
|
||||||
.iter()
|
.albums
|
||||||
.filter_map(|album_id| self.get_album(*album_id))
|
.iter()
|
||||||
.collect::<Vec<_>>();
|
.filter_map(|album_id| self.get_album(*album_id))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
albums.sort_by(|a, b| (a.year, &a.name).partial_cmp(&(b.year, &b.name)).unwrap());
|
||||||
|
albums
|
||||||
|
};
|
||||||
|
|
||||||
albums.sort_by(|a, b| (a.year, &a.name).partial_cmp(&(b.year, &b.name)).unwrap());
|
let album_appearances = {
|
||||||
|
let mut album_appearances = a
|
||||||
|
.album_appearances
|
||||||
|
.iter()
|
||||||
|
.filter_map(|album_id| self.get_album(*album_id))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
album_appearances.sort_by(|a, b| {
|
||||||
|
(&a.artists, a.year, &a.name)
|
||||||
|
.partial_cmp(&(&b.artists, b.year, &b.name))
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
album_appearances
|
||||||
|
};
|
||||||
|
|
||||||
collection::Artist {
|
collection::Artist {
|
||||||
name: a.name.clone(),
|
name: a.name.clone(),
|
||||||
albums: albums,
|
albums,
|
||||||
|
album_appearances,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ pub struct Directory {
|
||||||
pub struct Artist {
|
pub struct Artist {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub albums: Vec<Album>,
|
pub albums: Vec<Album>,
|
||||||
|
pub album_appearances: Vec<Album>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Eq)]
|
#[derive(Debug, Default, PartialEq, Eq)]
|
||||||
|
|
|
@ -305,6 +305,7 @@ impl From<collection::File> for BrowserEntry {
|
||||||
pub struct Artist {
|
pub struct Artist {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub albums: Vec<AlbumHeader>,
|
pub albums: Vec<AlbumHeader>,
|
||||||
|
pub album_appearances: Vec<AlbumHeader>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<collection::Artist> for Artist {
|
impl From<collection::Artist> for Artist {
|
||||||
|
@ -312,6 +313,7 @@ impl From<collection::Artist> for Artist {
|
||||||
Self {
|
Self {
|
||||||
name: a.name,
|
name: a.name,
|
||||||
albums: a.albums.into_iter().map(|a| a.into()).collect(),
|
albums: a.albums.into_iter().map(|a| a.into()).collect(),
|
||||||
|
album_appearances: a.album_appearances.into_iter().map(|a| a.into()).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue