mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
parent
b7458f6d9c
commit
4399724e97
3 changed files with 21 additions and 16 deletions
|
@ -18,4 +18,12 @@ namespace NzbDrone.Core.Profiles.Releases
|
|||
Tags = new HashSet<int>();
|
||||
}
|
||||
}
|
||||
|
||||
public class ReleaseProfilePreferredComparer : IComparer<KeyValuePair<string, int>>
|
||||
{
|
||||
public int Compare(KeyValuePair<string, int> x, KeyValuePair<string, int> y)
|
||||
{
|
||||
return y.Value.CompareTo(x.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,18 +18,24 @@ namespace NzbDrone.Core.Profiles.Releases
|
|||
|
||||
public class ReleaseProfileService : IReleaseProfileService
|
||||
{
|
||||
private readonly ReleaseProfilePreferredComparer _preferredComparer;
|
||||
private readonly IRestrictionRepository _repo;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ReleaseProfileService(IRestrictionRepository repo, Logger logger)
|
||||
{
|
||||
_preferredComparer = new ReleaseProfilePreferredComparer();
|
||||
|
||||
_repo = repo;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public List<ReleaseProfile> All()
|
||||
{
|
||||
return _repo.All().ToList();
|
||||
var all = _repo.All().ToList();
|
||||
all.ForEach(r => r.Preferred.Sort(_preferredComparer));
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
public List<ReleaseProfile> AllForTag(int tagId)
|
||||
|
@ -54,11 +60,15 @@ namespace NzbDrone.Core.Profiles.Releases
|
|||
|
||||
public ReleaseProfile Add(ReleaseProfile restriction)
|
||||
{
|
||||
restriction.Preferred.Sort(_preferredComparer);
|
||||
|
||||
return _repo.Insert(restriction);
|
||||
}
|
||||
|
||||
public ReleaseProfile Update(ReleaseProfile restriction)
|
||||
{
|
||||
restriction.Preferred.Sort(_preferredComparer);
|
||||
|
||||
return _repo.Update(restriction);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue