New: The Manual Search result table is now sorted by the internal prioritization logic and sorting by quality now works as well.

Tnx to mspec and betrayed for averting catastrophe.
This commit is contained in:
Taloth Saldono
2014-07-15 21:03:53 +02:00
parent d8543ad533
commit 8f192e635f
12 changed files with 151 additions and 73 deletions

View File

@@ -15,6 +15,7 @@ using Omu.ValueInjecter;
using System.Linq;
using Nancy.ModelBinding;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.Indexers
{
@@ -23,6 +24,7 @@ namespace NzbDrone.Api.Indexers
private readonly IFetchAndParseRss _rssFetcherAndParser;
private readonly ISearchForNzb _nzbSearchService;
private readonly IMakeDownloadDecision _downloadDecisionMaker;
private readonly IPrioritizeDownloadDecision _prioritizeDownloadDecision;
private readonly IDownloadService _downloadService;
private readonly IParsingService _parsingService;
private readonly Logger _logger;
@@ -30,6 +32,7 @@ namespace NzbDrone.Api.Indexers
public ReleaseModule(IFetchAndParseRss rssFetcherAndParser,
ISearchForNzb nzbSearchService,
IMakeDownloadDecision downloadDecisionMaker,
IPrioritizeDownloadDecision prioritizeDownloadDecision,
IDownloadService downloadService,
IParsingService parsingService,
Logger logger)
@@ -37,6 +40,7 @@ namespace NzbDrone.Api.Indexers
_rssFetcherAndParser = rssFetcherAndParser;
_nzbSearchService = nzbSearchService;
_downloadDecisionMaker = downloadDecisionMaker;
_prioritizeDownloadDecision = prioritizeDownloadDecision;
_downloadService = downloadService;
_parsingService = parsingService;
_logger = logger;
@@ -70,7 +74,9 @@ namespace NzbDrone.Api.Indexers
try
{
var decisions = _nzbSearchService.EpisodeSearch(episodeId);
return MapDecisions(decisions);
var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions);
return MapDecisions(prioritizedDecisions);
}
catch (Exception ex)
{
@@ -84,8 +90,9 @@ namespace NzbDrone.Api.Indexers
{
var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports);
var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions);
return MapDecisions(decisions);
return MapDecisions(prioritizedDecisions);
}
private static List<ReleaseResource> MapDecisions(IEnumerable<DownloadDecision> decisions)
@@ -102,6 +109,18 @@ namespace NzbDrone.Api.Indexers
release.Rejections = downloadDecision.Rejections.ToList();
release.DownloadAllowed = downloadDecision.RemoteEpisode.DownloadAllowed;
release.ReleaseWeight = result.Count;
if (downloadDecision.RemoteEpisode.Series != null)
{
release.QualityWeight = downloadDecision.RemoteEpisode.Series.QualityProfile.Value.Items.FindIndex(v => v.Quality == release.Quality.Quality) * 2;
}
if (!release.Quality.Proper)
{
release.QualityWeight++;
}
result.Add(release);
}