MonitoredSpec does not apply to searching

Fixed an issue where search specs weren't applied
This commit is contained in:
Mark McDowall
2013-08-06 20:18:05 -07:00
parent cd7a8bae78
commit f9092e95c2
25 changed files with 123 additions and 145 deletions
@@ -0,0 +1,49 @@
using System.Linq;
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
{
public class MonitoredEpisodeSpecification : IDecisionEngineSpecification
{
private readonly Logger _logger;
public MonitoredEpisodeSpecification(Logger logger)
{
_logger = logger;
}
public string RejectionReason
{
get
{
return "Series or Episode is not monitored";
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
{
if (searchCriteriaBase != null)
{
_logger.Trace("Skipping monitored check during search");
return true;
}
if (!subject.Series.Monitored)
{
_logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series);
return false;
}
//return monitored if any of the episodes are monitored
if (subject.Episodes.Any(episode => episode.Monitored))
{
return true;
}
_logger.Debug("No episodes are monitored. skipping.");
return false;
}
}
}