Removed SeasonService, fixed an issue with episode monitored status

This commit is contained in:
Mark McDowall 2013-09-12 20:50:12 -07:00
parent 3522ad0547
commit d64e902fa0
7 changed files with 17 additions and 22 deletions

View File

@ -9,17 +9,17 @@ namespace NzbDrone.Core.IndexerSearch
{ {
public class SeriesSearchService : IExecute<SeriesSearchCommand> public class SeriesSearchService : IExecute<SeriesSearchCommand>
{ {
private readonly ISeasonService _seasonService; private readonly ISeriesService _seriesService;
private readonly ISearchForNzb _nzbSearchService; private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports; private readonly IDownloadApprovedReports _downloadApprovedReports;
private readonly Logger _logger; private readonly Logger _logger;
public SeriesSearchService(ISeasonService seasonService, public SeriesSearchService(ISeriesService seriesService,
ISearchForNzb nzbSearchService, ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports, IDownloadApprovedReports downloadApprovedReports,
Logger logger) Logger logger)
{ {
_seasonService = seasonService; _seriesService = seriesService;
_nzbSearchService = nzbSearchService; _nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports; _downloadApprovedReports = downloadApprovedReports;
_logger = logger; _logger = logger;
@ -27,14 +27,11 @@ namespace NzbDrone.Core.IndexerSearch
public void Execute(SeriesSearchCommand message) public void Execute(SeriesSearchCommand message)
{ {
var seasons = _seasonService.GetSeasonsBySeries(message.SeriesId) var series = _seriesService.GetSeries(message.SeriesId);
.Where(s => s.SeasonNumber > 0)
.OrderBy(s => s.SeasonNumber)
.ToList();
var downloadedCount = 0; var downloadedCount = 0;
foreach (var season in seasons) foreach (var season in series.Seasons)
{ {
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber); var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
downloadedCount += _downloadApprovedReports.DownloadApproved(decisions).Count; downloadedCount += _downloadApprovedReports.DownloadApproved(decisions).Count;

View File

@ -419,7 +419,6 @@
<Compile Include="Providers\VideoFileInfoReader.cs" /> <Compile Include="Providers\VideoFileInfoReader.cs" />
<Compile Include="Download\Clients\PneumaticClient.cs" /> <Compile Include="Download\Clients\PneumaticClient.cs" />
<Compile Include="MediaFiles\RecycleBinProvider.cs" /> <Compile Include="MediaFiles\RecycleBinProvider.cs" />
<Compile Include="Tv\SeasonService.cs" />
<Compile Include="SeriesStats\SeriesStatistics.cs" /> <Compile Include="SeriesStats\SeriesStatistics.cs" />
<Compile Include="SeriesStats\SeriesStatisticsRepository.cs" /> <Compile Include="SeriesStats\SeriesStatisticsRepository.cs" />
<Compile Include="Tv\SeriesTypes.cs" /> <Compile Include="Tv\SeriesTypes.cs" />

View File

@ -15,15 +15,12 @@ namespace NzbDrone.Core.Tv
public class RefreshEpisodeService : IRefreshEpisodeService public class RefreshEpisodeService : IRefreshEpisodeService
{ {
private readonly IEpisodeService _episodeService; private readonly IEpisodeService _episodeService;
private readonly ISeasonService _seasonService;
private readonly IMessageAggregator _messageAggregator; private readonly IMessageAggregator _messageAggregator;
private readonly Logger _logger; private readonly Logger _logger;
public RefreshEpisodeService(IEpisodeService episodeService, public RefreshEpisodeService(IEpisodeService episodeService, IMessageAggregator messageAggregator, Logger logger)
ISeasonService seasonService, IMessageAggregator messageAggregator, Logger logger)
{ {
_episodeService = episodeService; _episodeService = episodeService;
_seasonService = seasonService;
_messageAggregator = messageAggregator; _messageAggregator = messageAggregator;
_logger = logger; _logger = logger;
} }
@ -35,7 +32,7 @@ namespace NzbDrone.Core.Tv
var failCount = 0; var failCount = 0;
var existingEpisodes = _episodeService.GetEpisodeBySeries(series.Id); var existingEpisodes = _episodeService.GetEpisodeBySeries(series.Id);
var seasons = _seasonService.GetSeasonsBySeries(series.Id); var seasons = series.Seasons;
var updateList = new List<Episode>(); var updateList = new List<Episode>();
var newList = new List<Episode>(); var newList = new List<Episode>();

View File

@ -80,7 +80,14 @@ namespace NzbDrone.Core.Tv
{ {
var existingSeason = series.Seasons.SingleOrDefault(s => s.SeasonNumber == season.SeasonNumber); var existingSeason = series.Seasons.SingleOrDefault(s => s.SeasonNumber == season.SeasonNumber);
if (existingSeason != null) //Todo: Should this should use the previous season's monitored state?
if (existingSeason == null)
{
_logger.Trace("New season ({0}) for series: [{1}] {2}, setting monitored to true", season.SeasonNumber, series.TvdbId, series.Title);
season.Monitored = true;
}
else
{ {
season.Monitored = existingSeason.Monitored; season.Monitored = existingSeason.Monitored;
} }

Binary file not shown.

View File

@ -119,11 +119,6 @@ namespace NzbDrone.Core.Tv
public Series UpdateSeries(Series series) public Series UpdateSeries(Series series)
{ {
foreach (var season in series.Seasons)
{
_episodeService.SetEpisodeMonitoredBySeason(series.Id, season.SeasonNumber, season.Monitored);
}
return _seriesRepository.Update(series); return _seriesRepository.Update(series);
} }