From d37b226fd4e54667c74857369357a8b30a9f38bf Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 24 Jan 2023 22:27:45 -0600 Subject: [PATCH] Fixed: Artist/album history loading Closes #3195 Fixes #3312 --- .../History/HistoryController.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Lidarr.Api.V1/History/HistoryController.cs b/src/Lidarr.Api.V1/History/HistoryController.cs index ecc41b7d7..e4517153b 100644 --- a/src/Lidarr.Api.V1/History/HistoryController.cs +++ b/src/Lidarr.Api.V1/History/HistoryController.cs @@ -12,6 +12,7 @@ using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.History; +using NzbDrone.Core.Music; namespace Lidarr.Api.V1.History { @@ -22,16 +23,19 @@ namespace Lidarr.Api.V1.History private readonly ICustomFormatCalculationService _formatCalculator; private readonly IUpgradableSpecification _upgradableSpecification; private readonly IFailedDownloadService _failedDownloadService; + private readonly IArtistService _artistService; public HistoryController(IHistoryService historyService, ICustomFormatCalculationService formatCalculator, IUpgradableSpecification upgradableSpecification, - IFailedDownloadService failedDownloadService) + IFailedDownloadService failedDownloadService, + IArtistService artistService) { _historyService = historyService; _formatCalculator = formatCalculator; _upgradableSpecification = upgradableSpecification; _failedDownloadService = failedDownloadService; + _artistService = artistService; } protected HistoryResource MapToResource(EntityHistory model, bool includeArtist, bool includeAlbum, bool includeTrack) @@ -101,12 +105,24 @@ namespace Lidarr.Api.V1.History [HttpGet("artist")] public List GetArtistHistory(int artistId, int? albumId = null, EntityHistoryEventType? eventType = null, bool includeArtist = false, bool includeAlbum = false, bool includeTrack = false) { + var artist = _artistService.GetArtist(artistId); + if (albumId.HasValue) { - return _historyService.GetByAlbum(albumId.Value, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList(); + return _historyService.GetByAlbum(albumId.Value, eventType).Select(h => + { + h.Artist = artist; + + return MapToResource(h, includeArtist, includeAlbum, includeTrack); + }).ToList(); } - return _historyService.GetByArtist(artistId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList(); + return _historyService.GetByArtist(artistId, eventType).Select(h => + { + h.Artist = artist; + + return MapToResource(h, includeArtist, includeAlbum, includeTrack); + }).ToList(); } [HttpPost("failed/{id}")]