You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/TrashLib/Sonarr/ReleaseProfile/Filters/StrictNegativeScoresFilter.cs

32 lines
834 B

using Serilog;
using TrashLib.Sonarr.Config;
namespace TrashLib.Sonarr.ReleaseProfile.Filters;
public class StrictNegativeScoresFilter : IReleaseProfileFilter
{
private readonly ILogger _log;
public StrictNegativeScoresFilter(ILogger log)
{
_log = log;
}
public ReleaseProfileData Transform(ReleaseProfileData profile, ReleaseProfileConfig config)
{
if (!config.StrictNegativeScores)
{
return profile;
}
_log.Debug("Negative scores will be strictly ignored");
var splitPreferred = profile.Preferred.ToLookup(x => x.Score < 0);
return profile with
{
Ignored = profile.Ignored.Concat(splitPreferred[true].SelectMany(x => x.Terms)).ToList(),
Preferred = splitPreferred[false].ToList()
};
}
}