Minor cleanup

This commit is contained in:
Mark McDowall 2019-07-21 17:12:44 -07:00
parent 1d9d665ed0
commit 5e4f7c5d8e
3 changed files with 9 additions and 10 deletions

View File

@ -15,12 +15,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
private readonly Logger _logger;
public QueueSpecification(IQueueService queueService,
UpgradableSpecification UpgradableSpecification,
UpgradableSpecification upgradableSpecification,
IPreferredWordService preferredWordServiceCalculator,
Logger logger)
{
_queueService = queueService;
_upgradableSpecification = UpgradableSpecification;
_upgradableSpecification = upgradableSpecification;
_preferredWordServiceCalculator = preferredWordServiceCalculator;
_logger = logger;
}
@ -31,8 +31,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
var queue = _queueService.GetQueue();
var matchingEpisode = queue.Where(q => q.RemoteEpisode != null &&
q.RemoteEpisode.Series != null &&
var matchingEpisode = queue.Where(q => q.RemoteEpisode?.Series != null &&
q.RemoteEpisode.Series.Id == subject.Series.Id &&
q.RemoteEpisode.Episodes.Select(e => e.Id).Intersect(subject.Episodes.Select(e => e.Id)).Any())
.ToList();

View File

@ -53,6 +53,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
{
var recent = mostRecent.Date.After(DateTime.UtcNow.AddHours(-12));
if (!recent && cdhEnabled)
{
continue;
}
// The series will be the same as the one in history since it's the same episode.
// Instead of fetching the series from the DB reuse the known series.
var preferredWordScore = _preferredWordServiceCalculator.Calculate(subject.Series, mostRecent.SourceTitle);
@ -76,11 +81,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
subject.ParsedEpisodeInfo.Language,
subject.PreferredWordScore);
if (!recent && cdhEnabled)
{
continue;
}
if (!cutoffUnmet)
{
if (recent)

View File

@ -51,7 +51,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
return Decision.Reject("Not an upgrade for existing episode file(s)");
}
if (languageComparer.Compare(localEpisode.Language, episodeFile.Language) < 0 && qualityCompare == 0)
if (languageComparer.Compare(localEpisode.Language, episodeFile.Language) < 0 && qualityCompare == 0)
{
_logger.Debug("This file isn't a language upgrade for all episodes. Skipping {0}", localEpisode.Path);
return Decision.Reject("Not an upgrade for existing episode file(s)");