fixup! New: Quality limits are part of Quality Profile

This commit is contained in:
Mark McDowall 2024-06-11 18:47:05 -07:00
parent 20e68c1d3c
commit ee84835d52
5 changed files with 38 additions and 25 deletions

View File

@ -1,9 +1,16 @@
// This file is automatically generated. // This file is automatically generated.
// Please do not change this file! // Please do not change this file!
interface CssExports { interface CssExports {
'megabytesPerMinute': string;
'quality': string; 'quality': string;
'qualityDefinition': string; 'qualityDefinition': string;
'sizeInput': string;
'sizeLimit': string;
'sizes': string;
'slider': string;
'thumb': string;
'title': string; 'title': string;
'track': string;
} }
export const cssExports: CssExports; export const cssExports: CssExports;
export default cssExports; export default cssExports;

View File

@ -3,8 +3,11 @@
interface CssExports { interface CssExports {
'definitions': string; 'definitions': string;
'header': string; 'header': string;
'notice': string; 'megabytesPerMinute': string;
'quality': string; 'quality': string;
'sizeLimit': string;
'sizeLimitHelpText': string;
'sizeLimitHelpTextContainer': string;
'title': string; 'title': string;
} }
export const cssExports: CssExports; export const cssExports: CssExports;

View File

@ -22,21 +22,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestFixture] [TestFixture]
public class PrioritizeDownloadDecisionFixture : CoreTest<DownloadDecisionPriorizationService> public class PrioritizeDownloadDecisionFixture : CoreTest<DownloadDecisionPriorizationService>
{ {
private Series _series;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
GivenPreferredDownloadProtocol(DownloadProtocol.Usenet); GivenPreferredDownloadProtocol(DownloadProtocol.Usenet);
Mocker.GetMock<IQualityDefinitionService>() _series = Builder<Series>.CreateNew()
.Setup(s => s.Get(It.IsAny<Quality>())) .With(e => e.Runtime = 60)
.Returns(new QualityDefinition { PreferredSize = null }); .With(e => e.QualityProfile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities()
})
.Build();
} }
private void GivenPreferredSize(double? size) private void GivenPreferredSize(QualityProfile qualityProfile, double? size)
{ {
Mocker.GetMock<IQualityDefinitionService>() foreach (var qualityOrGroup in qualityProfile.Items)
.Setup(s => s.Get(It.IsAny<Quality>())) {
.Returns(new QualityDefinition { PreferredSize = size }); if (qualityOrGroup.Quality != null)
{
qualityOrGroup.PreferredSize = size;
}
else
{
qualityOrGroup.Items.ForEach(i => i.PreferredSize = size);
}
}
} }
private Episode GivenEpisode(int id) private Episode GivenEpisode(int id)
@ -63,13 +77,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteEpisode.Release.DownloadProtocol = downloadProtocol; remoteEpisode.Release.DownloadProtocol = downloadProtocol;
remoteEpisode.Release.IndexerPriority = indexerPriority; remoteEpisode.Release.IndexerPriority = indexerPriority;
remoteEpisode.Series = Builder<Series>.CreateNew() remoteEpisode.Series = _series;
.With(e => e.Runtime = 60)
.With(e => e.QualityProfile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities()
})
.Build();
return remoteEpisode; return remoteEpisode;
} }
@ -176,7 +184,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_order_by_closest_to_preferred_size_if_both_under() public void should_order_by_closest_to_preferred_size_if_both_under()
{ {
// 200 MB/Min * 60 Min Runtime = 12000 MB // 200 MB/Min * 60 Min Runtime = 12000 MB
GivenPreferredSize(200); GivenPreferredSize(_series.QualityProfile.Value, 200);
var remoteEpisodeSmall = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 1200.Megabytes(), age: 1); var remoteEpisodeSmall = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 1200.Megabytes(), age: 1);
var remoteEpisodeLarge = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 10000.Megabytes(), age: 1); var remoteEpisodeLarge = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 10000.Megabytes(), age: 1);
@ -193,7 +201,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_order_by_closest_to_preferred_size_if_preferred_is_in_between() public void should_order_by_closest_to_preferred_size_if_preferred_is_in_between()
{ {
// 46 MB/Min * 60 Min Runtime = 6900 MB // 46 MB/Min * 60 Min Runtime = 6900 MB
GivenPreferredSize(46); GivenPreferredSize(_series.QualityProfile.Value, 46);
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 500.Megabytes(), age: 1); var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 500.Megabytes(), age: 1);
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 2000.Megabytes(), age: 1); var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 2000.Megabytes(), age: 1);

View File

@ -14,16 +14,14 @@ namespace NzbDrone.Core.DecisionEngine
{ {
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly IDelayProfileService _delayProfileService; private readonly IDelayProfileService _delayProfileService;
private readonly IQualityDefinitionService _qualityDefinitionService;
public delegate int CompareDelegate(DownloadDecision x, DownloadDecision y); public delegate int CompareDelegate(DownloadDecision x, DownloadDecision y);
public delegate int CompareDelegate<TSubject, TValue>(DownloadDecision x, DownloadDecision y); public delegate int CompareDelegate<TSubject, TValue>(DownloadDecision x, DownloadDecision y);
public DownloadDecisionComparer(IConfigService configService, IDelayProfileService delayProfileService, IQualityDefinitionService qualityDefinitionService) public DownloadDecisionComparer(IConfigService configService, IDelayProfileService delayProfileService)
{ {
_configService = configService; _configService = configService;
_delayProfileService = delayProfileService; _delayProfileService = delayProfileService;
_qualityDefinitionService = qualityDefinitionService;
} }
public int Compare(DownloadDecision x, DownloadDecision y) public int Compare(DownloadDecision x, DownloadDecision y)

View File

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Core.DecisionEngine namespace NzbDrone.Core.DecisionEngine
{ {
@ -15,13 +14,11 @@ namespace NzbDrone.Core.DecisionEngine
{ {
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly IDelayProfileService _delayProfileService; private readonly IDelayProfileService _delayProfileService;
private readonly IQualityDefinitionService _qualityDefinitionService;
public DownloadDecisionPriorizationService(IConfigService configService, IDelayProfileService delayProfileService, IQualityDefinitionService qualityDefinitionService) public DownloadDecisionPriorizationService(IConfigService configService, IDelayProfileService delayProfileService)
{ {
_configService = configService; _configService = configService;
_delayProfileService = delayProfileService; _delayProfileService = delayProfileService;
_qualityDefinitionService = qualityDefinitionService;
} }
public List<DownloadDecision> PrioritizeDecisions(List<DownloadDecision> decisions) public List<DownloadDecision> PrioritizeDecisions(List<DownloadDecision> decisions)
@ -29,7 +26,7 @@ namespace NzbDrone.Core.DecisionEngine
return decisions.Where(c => c.RemoteEpisode.Series != null) return decisions.Where(c => c.RemoteEpisode.Series != null)
.GroupBy(c => c.RemoteEpisode.Series.Id, (seriesId, downloadDecisions) => .GroupBy(c => c.RemoteEpisode.Series.Id, (seriesId, downloadDecisions) =>
{ {
return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_configService, _delayProfileService, _qualityDefinitionService)); return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_configService, _delayProfileService));
}) })
.SelectMany(c => c) .SelectMany(c => c)
.Union(decisions.Where(c => c.RemoteEpisode.Series == null)) .Union(decisions.Where(c => c.RemoteEpisode.Series == null))