Skip to content

Commit

Permalink
Correct artist statistics calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
davewalker5 committed Nov 10, 2023
1 parent 1813977 commit 35b3a23
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/MusicCatalogue.Logic/Database/StatisticsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ public async Task PopulateArtistStatistics(IEnumerable<Artist> artists, bool wis
// Iterate over the supplied list
foreach (var artist in artists)
{
// If the albums are already attached, use that list to calculate the statistics. Otherwise,
// load the albums from the database
var albums = artist.Albums;
if ((albums?.Count ?? 0) == 0)
List<Album> albums;

// Make sure the tracks and albums are loaded - the wish list flag is either null, false or true
if (wishlist)
{
albums = await _factory.Albums.ListAsync(x => (x.ArtistId == artist.Id) && (x.IsWishListItem == true));
}
else
{
albums = await _factory.Albums.ListAsync(x => x.ArtistId == artist.Id);
albums = await _factory.Albums.ListAsync(x => (x.ArtistId == artist.Id) && (x.IsWishListItem != true));
}

// Count the albums and tracks
Expand Down

0 comments on commit 35b3a23

Please sign in to comment.