mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
some preliminary work to move decision engine to use the visitor pattern.
This commit is contained in:
parent
969dff5197
commit
02d842a2b2
51 changed files with 470 additions and 507 deletions
|
@ -0,0 +1,43 @@
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
{
|
||||
public class CustomStartDateSpecification : IFetchableSpecification
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public CustomStartDateSpecification(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string RejectionReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Aired before configured cut-off";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
if (!subject.Series.CustomStartDate.HasValue)
|
||||
{
|
||||
_logger.Debug("{0} does not restrict downloads before date.", subject.Series.Title);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (subject.Episodes.Any(episode => episode.AirDate >= subject.Series.CustomStartDate.Value))
|
||||
{
|
||||
_logger.Debug("One or more episodes aired after cutoff, downloading.");
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.Debug("Episodes aired before cutoff date: {0}", subject.Series.CustomStartDate);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue