Search all missing fixes

Fixed: Searching for missing episodes excludes unmonitored episodes
Fixed: Searching for missing episodes episodes with files
pull/3113/head
Mark McDowall 10 years ago
parent ccfd66260d
commit 0adea0ded6

@ -138,7 +138,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, 1);
Subject.SeasonSearch(_xemSeries.Id, 1, false);
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
@ -153,7 +153,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, 2);
Subject.SeasonSearch(_xemSeries.Id, 2, false);
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
@ -169,7 +169,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, 4);
Subject.SeasonSearch(_xemSeries.Id, 4, false);
var criteria1 = allCriteria.OfType<SeasonSearchCriteria>().ToList();
var criteria2 = allCriteria.OfType<SingleEpisodeSearchCriteria>().ToList();
@ -189,7 +189,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, 7);
Subject.SeasonSearch(_xemSeries.Id, 7, false);
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
@ -202,11 +202,12 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
{
WithEpisodes();
_xemSeries.SeriesType = SeriesTypes.Anime;
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
var seasonNumber = 1;
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, seasonNumber);
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
@ -219,11 +220,29 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
WithEpisodes();
_xemSeries.SeriesType = SeriesTypes.Anime;
_xemEpisodes.ForEach(e => e.Monitored = false);
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
var seasonNumber = 1;
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, seasonNumber);
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
criteria.Count.Should().Be(0);
}
[Test]
public void season_search_for_anime_should_not_search_for_episodes_with_files()
{
WithEpisodes();
_xemSeries.SeriesType = SeriesTypes.Anime;
_xemEpisodes.ForEach(e => e.EpisodeFileId = 1);
var seasonNumber = 1;
var allCriteria = WatchForSearchCriteria();
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
.Returns(_series);
Mocker.GetMock<ISearchForNzb>()
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>()))
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>(), false))
.Returns(new List<DownloadDecision>());
Mocker.GetMock<IProcessDownloadDecisions>()
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
Subject.Execute(new SeriesSearchCommand{ SeriesId = _series.Id });
Mocker.GetMock<ISearchForNzb>()
.Verify(v => v.SeasonSearch(_series.Id, It.IsAny<Int32>()), Times.Exactly(_series.Seasons.Count(s => s.Monitored)));
.Verify(v => v.SeasonSearch(_series.Id, It.IsAny<Int32>(), false), Times.Exactly(_series.Seasons.Count(s => s.Monitored)));
}
[Test]
@ -68,9 +68,9 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
};
Mocker.GetMock<ISearchForNzb>()
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>()))
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>(), false))
.Returns(new List<DownloadDecision>())
.Callback<Int32, Int32>((seriesId, seasonNumber) => seasonOrder.Add(seasonNumber));
.Callback<int, int, bool>((seriesId, seasonNumber, missingOnly) => seasonOrder.Add(seasonNumber));
Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id });

@ -80,7 +80,7 @@ namespace NzbDrone.Core.IndexerSearch
if (season.Count() > 1)
{
decisions = _nzbSearchService.SeasonSearch(series.Key, season.Key);
decisions = _nzbSearchService.SeasonSearch(series.Key, season.Key, true);
}
else

@ -19,7 +19,7 @@ namespace NzbDrone.Core.IndexerSearch
{
List<DownloadDecision> EpisodeSearch(int episodeId);
List<DownloadDecision> EpisodeSearch(Episode episode);
List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber);
List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber, bool missingOnly);
}
public class NzbSearchService : ISearchForNzb
@ -80,11 +80,16 @@ namespace NzbDrone.Core.IndexerSearch
return SearchSingle(series, episode);
}
public List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber)
public List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber, bool missingOnly)
{
var series = _seriesService.GetSeries(seriesId);
var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
if (missingOnly)
{
episodes = episodes.Where(e => e.Monitored && !e.HasFile).ToList();
}
if (series.SeriesType == SeriesTypes.Anime)
{
return SearchAnimeSeason(series, episodes);
@ -217,10 +222,7 @@ namespace NzbDrone.Core.IndexerSearch
foreach (var episode in episodes)
{
if (episode.Monitored)
{
downloadDecisions.AddRange(SearchAnime(series, episode));
}
downloadDecisions.AddRange(SearchAnime(series, episode));
}
return downloadDecisions;

@ -22,7 +22,7 @@ namespace NzbDrone.Core.IndexerSearch
public void Execute(SeasonSearchCommand message)
{
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber);
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber, false);
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
_logger.ProgressInfo("Season search completed. {0} reports downloaded.", processed.Grabbed.Count);

@ -39,7 +39,7 @@ namespace NzbDrone.Core.IndexerSearch
continue;
}
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber, false);
downloadedCount += _processDownloadDecisions.ProcessDecisions(decisions).Grabbed.Count;
}

Loading…
Cancel
Save