diff --git a/frontend/src/Settings/Quality/Definition/QualityDefinition.css.d.ts b/frontend/src/Settings/Quality/Definition/QualityDefinition.css.d.ts index 15079647b..56c2f5d98 100644 --- a/frontend/src/Settings/Quality/Definition/QualityDefinition.css.d.ts +++ b/frontend/src/Settings/Quality/Definition/QualityDefinition.css.d.ts @@ -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; diff --git a/frontend/src/Settings/Quality/Definition/QualityDefinitions.css.d.ts b/frontend/src/Settings/Quality/Definition/QualityDefinitions.css.d.ts index 6342b91dc..72ba4f3a3 100644 --- a/frontend/src/Settings/Quality/Definition/QualityDefinitions.css.d.ts +++ b/frontend/src/Settings/Quality/Definition/QualityDefinitions.css.d.ts @@ -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; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs index 2c9c05362..9c2120212 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs @@ -22,21 +22,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class PrioritizeDownloadDecisionFixture : CoreTest { + private Series _series; + [SetUp] public void Setup() { GivenPreferredDownloadProtocol(DownloadProtocol.Usenet); - Mocker.GetMock() - .Setup(s => s.Get(It.IsAny())) - .Returns(new QualityDefinition { PreferredSize = null }); + _series = Builder.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() - .Setup(s => s.Get(It.IsAny())) - .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.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 { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 1200.Megabytes(), age: 1); var remoteEpisodeLarge = GivenRemoteEpisode(new List { 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 { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 500.Megabytes(), age: 1); var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.HDTV720p), Language.English, size: 2000.Megabytes(), age: 1); diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs index 64277b34e..f5996bf58 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs @@ -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(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) diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs index 44808ee05..69c49c480 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs @@ -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 PrioritizeDecisions(List 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))