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.
// Please do not change this file!
interface CssExports {
'megabytesPerMinute': string;
'quality': string;
'qualityDefinition': string;
'sizeInput': string;
'sizeLimit': string;
'sizes': string;
'slider': string;
'thumb': string;
'title': string;
'track': string;
}
export const cssExports: CssExports;
export default cssExports;

View File

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

View File

@ -22,21 +22,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestFixture]
public class PrioritizeDownloadDecisionFixture : CoreTest<DownloadDecisionPriorizationService>
{
private Series _series;
[SetUp]
public void Setup()
{
GivenPreferredDownloadProtocol(DownloadProtocol.Usenet);
Mocker.GetMock<IQualityDefinitionService>()
.Setup(s => s.Get(It.IsAny<Quality>()))
.Returns(new QualityDefinition { PreferredSize = null });
_series = Builder<Series>.CreateNew()
.With(e => e.Runtime = 60)
.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>()
.Setup(s => s.Get(It.IsAny<Quality>()))
.Returns(new QualityDefinition { PreferredSize = size });
foreach (var qualityOrGroup in qualityProfile.Items)
{
if (qualityOrGroup.Quality != null)
{
qualityOrGroup.PreferredSize = size;
}
else
{
qualityOrGroup.Items.ForEach(i => i.PreferredSize = size);
}
}
}
private Episode GivenEpisode(int id)
@ -63,13 +77,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteEpisode.Release.DownloadProtocol = downloadProtocol;
remoteEpisode.Release.IndexerPriority = indexerPriority;
remoteEpisode.Series = Builder<Series>.CreateNew()
.With(e => e.Runtime = 60)
.With(e => e.QualityProfile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities()
})
.Build();
remoteEpisode.Series = _series;
return remoteEpisode;
}
@ -176,7 +184,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_order_by_closest_to_preferred_size_if_both_under()
{
// 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 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()
{
// 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 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 IDelayProfileService _delayProfileService;
private readonly IQualityDefinitionService _qualityDefinitionService;
public delegate int CompareDelegate(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;
_delayProfileService = delayProfileService;
_qualityDefinitionService = qualityDefinitionService;
}
public int Compare(DownloadDecision x, DownloadDecision y)

View File

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