Fixed: Sorting in Interactive search duplicates results

Fixes #5760
Fixes #5765

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
Co-Authored-By: Taloth <Taloth@users.noreply.github.com>
pull/5848/head
Qstick 4 years ago
parent 539fcb91c9
commit a1db7a8f1e

@ -56,9 +56,14 @@ namespace NzbDrone.Core.IndexerSearch
public List<DownloadDecision> MovieSearch(Movie movie, bool userInvokedSearch, bool interactiveSearch)
{
var downloadDecisions = new List<DownloadDecision>();
var searchSpec = Get<MovieSearchCriteria>(movie, userInvokedSearch, interactiveSearch);
return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec);
var decisions = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec);
downloadDecisions.AddRange(decisions);
return DeDupeDecisions(downloadDecisions);
}
private TSpec Get<TSpec>(Movie movie, bool userInvokedSearch, bool interactiveSearch)
@ -132,5 +137,11 @@ namespace NzbDrone.Core.IndexerSearch
return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList();
}
private List<DownloadDecision> DeDupeDecisions(List<DownloadDecision> decisions)
{
// De-dupe reports by guid so duplicate results aren't returned. Pick the one with the least rejections.
return decisions.GroupBy(d => d.RemoteMovie.Release.Guid).Select(d => d.OrderBy(v => v.Rejections.Count()).First()).ToList();
}
}
}

Loading…
Cancel
Save