1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 20:42:37 +01:00

Fixed: Delete all history for series when series is removed from Sonarr

This commit is contained in:
Mark McDowall 2016-07-20 15:53:49 -07:00
parent 857d661ff1
commit b232cc3081
2 changed files with 14 additions and 1 deletions

View File

@ -15,6 +15,7 @@ public interface IHistoryRepository : IBasicRepository<History>
History MostRecentForDownloadId(string downloadId); History MostRecentForDownloadId(string downloadId);
List<History> FindByDownloadId(string downloadId); List<History> FindByDownloadId(string downloadId);
List<History> FindDownloadHistory(int idSeriesId, QualityModel quality); List<History> FindDownloadHistory(int idSeriesId, QualityModel quality);
void DeleteForSeries(int seriesId);
} }
public class HistoryRepository : BasicRepository<History>, IHistoryRepository public class HistoryRepository : BasicRepository<History>, IHistoryRepository
@ -63,6 +64,11 @@ public List<History> FindDownloadHistory(int idSeriesId, QualityModel quality)
).ToList(); ).ToList();
} }
public void DeleteForSeries(int seriesId)
{
Delete(c => c.SeriesId == seriesId);
}
protected override SortBuilder<History> GetPagedQuery(QueryBuilder<History> query, PagingSpec<History> pagingSpec) protected override SortBuilder<History> GetPagedQuery(QueryBuilder<History> query, PagingSpec<History> pagingSpec)
{ {
var baseQuery = query.Join<History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) var baseQuery = query.Join<History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id)

View File

@ -13,6 +13,7 @@
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles; using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.History namespace NzbDrone.Core.History
{ {
@ -31,7 +32,8 @@ public class HistoryService : IHistoryService,
IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeImportedEvent>, IHandle<EpisodeImportedEvent>,
IHandle<DownloadFailedEvent>, IHandle<DownloadFailedEvent>,
IHandle<EpisodeFileDeletedEvent> IHandle<EpisodeFileDeletedEvent>,
IHandle<SeriesDeletedEvent>
{ {
private readonly IHistoryRepository _historyRepository; private readonly IHistoryRepository _historyRepository;
private readonly Logger _logger; private readonly Logger _logger;
@ -255,5 +257,10 @@ public void Handle(EpisodeFileDeletedEvent message)
_historyRepository.Insert(history); _historyRepository.Insert(history);
} }
} }
public void Handle(SeriesDeletedEvent message)
{
_historyRepository.DeleteForSeries(message.Series.Id);
}
} }
} }