mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-24 22:35:49 -04:00
New: User defined scores for each Custom Format
Brings it more into line with Sonarr preferred words
This commit is contained in:
@@ -17,13 +17,6 @@ namespace NzbDrone.Core.CustomFormats
|
||||
Specifications = specs.ToList();
|
||||
}
|
||||
|
||||
public static CustomFormat None => new CustomFormat
|
||||
{
|
||||
Id = 0,
|
||||
Name = "None",
|
||||
Specifications = new List<ICustomFormatSpecification>()
|
||||
};
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<ICustomFormatSpecification> Specifications { get; set; }
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Core.Profiles;
|
||||
|
||||
namespace NzbDrone.Core.CustomFormats
|
||||
{
|
||||
public class CustomFormatsComparer : IComparer<List<CustomFormat>>
|
||||
{
|
||||
private readonly Profile _profile;
|
||||
|
||||
public CustomFormatsComparer(Profile profile)
|
||||
{
|
||||
Ensure.That(profile, () => profile).IsNotNull();
|
||||
Ensure.That(profile.Items, () => profile.Items).HasItems();
|
||||
|
||||
_profile = profile;
|
||||
}
|
||||
|
||||
public int Compare(List<CustomFormat> left, List<CustomFormat> right)
|
||||
{
|
||||
var leftIndicies = _profile.GetIndices(left);
|
||||
var rightIndicies = _profile.GetIndices(right);
|
||||
|
||||
// Summing powers of two ensures last format always trumps, but we order correctly if we
|
||||
// have extra formats lower down the list
|
||||
var leftTotal = leftIndicies.Select(x => Math.Pow(2, x)).Sum();
|
||||
var rightTotal = rightIndicies.Select(x => Math.Pow(2, x)).Sum();
|
||||
|
||||
return leftTotal.CompareTo(rightTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user