fixup! New: Match only custom formats with score
This commit is contained in:
parent
5b41c710f6
commit
9b42cd4943
|
@ -56,13 +56,13 @@ class QualityProfileFormatItem extends Component {
|
||||||
QualityProfileFormatItem.propTypes = {
|
QualityProfileFormatItem.propTypes = {
|
||||||
formatId: PropTypes.number.isRequired,
|
formatId: PropTypes.number.isRequired,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
score: PropTypes.number,
|
score: PropTypes.number.isRequired,
|
||||||
onScoreChange: PropTypes.func
|
onScoreChange: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
QualityProfileFormatItem.defaultProps = {
|
QualityProfileFormatItem.defaultProps = {
|
||||||
// To handle the case score is deleted during edit
|
// To handle the case score is deleted during edit
|
||||||
score: null
|
score: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
export default QualityProfileFormatItem;
|
export default QualityProfileFormatItem;
|
||||||
|
|
|
@ -18,14 +18,6 @@ function calcOrder(profileFormatItems) {
|
||||||
|
|
||||||
return [...profileFormatItems].sort((a, b) => {
|
return [...profileFormatItems].sort((a, b) => {
|
||||||
if (b.score !== a.score) {
|
if (b.score !== a.score) {
|
||||||
if (a.score === null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.score === null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.score - a.score;
|
return b.score - a.score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace NzbDrone.Core.CustomFormats
|
||||||
var matches = new List<CustomFormat>();
|
var matches = new List<CustomFormat>();
|
||||||
|
|
||||||
var profileFormatItems = input.Series?.QualityProfile?.Value?.FormatItems
|
var profileFormatItems = input.Series?.QualityProfile?.Value?.FormatItems
|
||||||
.Where(f => f.Score.HasValue)
|
.Where(f => f.Enabled)
|
||||||
.Select(f => f.Format)
|
.Select(f => f.Format)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace NzbDrone.Core.Profiles
|
||||||
public class ProfileFormatItem : IEmbeddedDocument
|
public class ProfileFormatItem : IEmbeddedDocument
|
||||||
{
|
{
|
||||||
public CustomFormat Format { get; set; }
|
public CustomFormat Format { get; set; }
|
||||||
public int? Score { get; set; }
|
public int Score { get; set; }
|
||||||
|
public bool Enabled { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Profiles.Qualities
|
||||||
|
|
||||||
public int CalculateCustomFormatScore(List<CustomFormat> formats)
|
public int CalculateCustomFormatScore(List<CustomFormat> formats)
|
||||||
{
|
{
|
||||||
return FormatItems.Where(x => x.Score.HasValue && formats.Contains(x.Format)).Sum(x => x.Score.Value);
|
return FormatItems.Where(x => x.Enabled && formats.Contains(x.Format)).Sum(x => x.Score);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using NzbDrone.Core.CustomFormats;
|
using NzbDrone.Core.CustomFormats;
|
||||||
using NzbDrone.Core.Profiles;
|
using NzbDrone.Core.Profiles;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
|
@ -36,9 +35,8 @@ namespace Sonarr.Api.V3.Profiles.Quality
|
||||||
{
|
{
|
||||||
public int Format { get; set; }
|
public int Format { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public int Score { get; set; }
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
public bool Enabled { get; set; } = true;
|
||||||
public int? Score { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ProfileResourceMapper
|
public static class ProfileResourceMapper
|
||||||
|
@ -86,7 +84,8 @@ namespace Sonarr.Api.V3.Profiles.Quality
|
||||||
{
|
{
|
||||||
Format = model.Format.Id,
|
Format = model.Format.Id,
|
||||||
Name = model.Format.Name,
|
Name = model.Format.Name,
|
||||||
Score = model.Score
|
Score = model.Score,
|
||||||
|
Enabled = model.Enabled
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +131,8 @@ namespace Sonarr.Api.V3.Profiles.Quality
|
||||||
return new ProfileFormatItem
|
return new ProfileFormatItem
|
||||||
{
|
{
|
||||||
Format = new CustomFormat { Id = resource.Format },
|
Format = new CustomFormat { Id = resource.Format },
|
||||||
Score = resource.Score
|
Score = resource.Score,
|
||||||
|
Enabled = resource.Enabled
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue