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

pull/4/head
kay.one 13 years ago
parent 5bf56ffca3
commit ac84d76ef9

@ -91,8 +91,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new Quality(QualityTypes.DVD, true))
.With(c => c.Age = 10)
.Random(1)
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
.With(c => c.Age = 100)
.Build();
WithMatchingSeries();
@ -115,6 +117,37 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
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]
public void processSearchResults_when_quality_is_not_needed_should_check_the_rest()
{

@ -231,7 +231,7 @@ namespace NzbDrone.Core.Providers
{
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
{

Loading…
Cancel
Save