diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index c8bc10f04..35199a878 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -15,6 +15,7 @@ namespace NzbDrone.Core.History History MostRecentForDownloadId(string downloadId); List FindByDownloadId(string downloadId); List FindDownloadHistory(int idSeriesId, QualityModel quality); + void DeleteForSeries(int seriesId); } public class HistoryRepository : BasicRepository, IHistoryRepository @@ -63,6 +64,11 @@ namespace NzbDrone.Core.History ).ToList(); } + public void DeleteForSeries(int seriesId) + { + Delete(c => c.SeriesId == seriesId); + } + protected override SortBuilder GetPagedQuery(QueryBuilder query, PagingSpec pagingSpec) { var baseQuery = query.Join(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index 1db2e7778..9459a4fcc 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -13,6 +13,7 @@ using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; +using NzbDrone.Core.Tv.Events; namespace NzbDrone.Core.History { @@ -31,7 +32,8 @@ namespace NzbDrone.Core.History IHandle, IHandle, IHandle, - IHandle + IHandle, + IHandle { private readonly IHistoryRepository _historyRepository; private readonly Logger _logger; @@ -255,5 +257,10 @@ namespace NzbDrone.Core.History _historyRepository.Insert(history); } } + + public void Handle(SeriesDeletedEvent message) + { + _historyRepository.DeleteForSeries(message.Series.Id); + } } } \ No newline at end of file