From 35b3a23e8ae8784ef35d34f0da4cffc5202eaa19 Mon Sep 17 00:00:00 2001 From: Dave Walker Date: Fri, 10 Nov 2023 10:18:45 +0000 Subject: [PATCH] Correct artist statistics calculation --- .../Database/StatisticsManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/MusicCatalogue.Logic/Database/StatisticsManager.cs b/src/MusicCatalogue.Logic/Database/StatisticsManager.cs index e3d758c..1aa1743 100644 --- a/src/MusicCatalogue.Logic/Database/StatisticsManager.cs +++ b/src/MusicCatalogue.Logic/Database/StatisticsManager.cs @@ -23,12 +23,16 @@ public async Task PopulateArtistStatistics(IEnumerable 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 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