From b70ef368dbadcce8bfd09b2fed7fa871df70a3f1 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 3 Nov 2021 17:21:03 -0700 Subject: [PATCH] Fixed: api/v3/history/series "includeSeries" and "includeEpisode" query parameters Closes #4727 --- src/NzbDrone.Core/History/HistoryRepository.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index 11b6c9153..b3be6b3fe 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -58,7 +58,9 @@ namespace NzbDrone.Core.History public List GetBySeries(int seriesId, EpisodeHistoryEventType? eventType) { - var query = Query.Where(h => h.SeriesId == seriesId); + var query = Query.Join(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) + .Join(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id) + .Where(h => h.SeriesId == seriesId); if (eventType.HasValue) { @@ -70,9 +72,11 @@ namespace NzbDrone.Core.History public List GetBySeason(int seriesId, int seasonNumber, EpisodeHistoryEventType? eventType) { - var query = Query.Join(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id) - .Where(h => h.SeriesId == seriesId) - .AndWhere(h => h.Episode.SeasonNumber == seasonNumber); + SortBuilder query = Query + .Join(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id) + .Join(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) + .Where(h => h.SeriesId == seriesId) + .AndWhere(h => h.Episode.SeasonNumber == seasonNumber); if (eventType.HasValue) {