1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 01:37:07 +00:00

New: When searching for episodes, newer reports are given priority over older reports of equal quality.

This commit is contained in:
kay.one 2012-02-18 11:20:18 -08:00
parent 5bf56ffca3
commit ac84d76ef9
2 changed files with 35 additions and 2 deletions

View file

@ -91,8 +91,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
.With(e => e.SeasonNumber = 1) .With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 }) .With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true)) .With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Age = 10)
.Random(1) .Random(1)
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true)) .With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 100)
.Build(); .Build();
WithMatchingSeries(); WithMatchingSeries();
@ -115,6 +117,37 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
Times.Once()); Times.Once());
} }
[Test]
public void processSearchResults_newer_report_should_be_called_first()
{
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 300)
.Build();
parseResults[2].Age = 100;
WithMatchingSeries();
WithSuccessfulDownload();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
//Act
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(MockNotification, parseResults, _matchingSeries, 1, 1);
//Assert
result.Should().HaveCount(1);
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Age != 100)), Times.Never());
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Age == 100)), Times.Once());
}
[Test] [Test]
public void processSearchResults_when_quality_is_not_needed_should_check_the_rest() public void processSearchResults_when_quality_is_not_needed_should_check_the_rest()
{ {
@ -233,7 +266,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
.With(e => e.EpisodeNumbers = new List<int> { 5 }) .With(e => e.EpisodeNumbers = new List<int> { 5 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true)) .With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.TheLast(1) .TheLast(1)
.With(e => e.EpisodeNumbers = new List<int> { 1,2,3,4,5 }) .With(e => e.EpisodeNumbers = new List<int> { 1, 2, 3, 4, 5 })
.Build(); .Build();
WithMatchingSeries(); WithMatchingSeries();

View file

@ -231,7 +231,7 @@ namespace NzbDrone.Core.Providers
{ {
var successes = new List<int>(); var successes = new List<int>();
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality)) foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality).ThenBy(c => c.Age))
{ {
try try
{ {