Files
Readarr/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs
T
ta264 c98b86b413 Fixed: Allow downloading any search result (#525)
* Allow downloading any search result

Ones that couldn't be parsed get a red icon

* Not required - initialized to false

* Add a warning the the queue page for manual downloads
2018-11-11 00:38:38 -05:00

35 lines
1.3 KiB
C#

using System.Linq;
using System.Collections.Generic;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Languages;
namespace NzbDrone.Core.DecisionEngine
{
public interface IPrioritizeDownloadDecision
{
List<DownloadDecision> PrioritizeDecisions(List<DownloadDecision> decisions);
}
public class DownloadDecisionPriorizationService : IPrioritizeDownloadDecision
{
private readonly IDelayProfileService _delayProfileService;
public DownloadDecisionPriorizationService(IDelayProfileService delayProfileService)
{
_delayProfileService = delayProfileService;
}
public List<DownloadDecision> PrioritizeDecisions(List<DownloadDecision> decisions)
{
return decisions.Where(c => c.RemoteAlbum.DownloadAllowed)
.GroupBy(c => c.RemoteAlbum.Artist.Id, (artistId, downloadDecisions) =>
{
return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_delayProfileService));
})
.SelectMany(c => c)
.Union(decisions.Where(c => !c.RemoteAlbum.DownloadAllowed))
.ToList();
}
}
}