Fixed: Performance issues when processing results from indexers (RSS/Search)
This commit is contained in:
parent
0a837be9ff
commit
78dacf6850
|
@ -21,9 +21,7 @@ namespace NzbDrone.Core.Configuration
|
||||||
|
|
||||||
public Config Get(string key)
|
public Config Get(string key)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(c => c.Key == key);
|
return Query.Where(c => c.Key == key).SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using Marr.Data;
|
using Marr.Data;
|
||||||
using Marr.Data.QGen;
|
using Marr.Data.QGen;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
|
@ -74,7 +73,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
|
|
||||||
public TModel Get(int id)
|
public TModel Get(int id)
|
||||||
{
|
{
|
||||||
var model = DataMapper.Query<TModel>().SingleOrDefault(c => c.Id == id);
|
var model = Query.Where(c => c.Id == id).SingleOrDefault();
|
||||||
|
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace NzbDrone.Core.DecisionEngine
|
||||||
private readonly IParsingService _parsingService;
|
private readonly IParsingService _parsingService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public DownloadDecisionMaker(IEnumerable<IRejectWithReason> specifications, IParsingService parsingService, Logger logger)
|
public DownloadDecisionMaker(IEnumerable<IDecisionEngineSpecification> specifications, IParsingService parsingService, Logger logger)
|
||||||
{
|
{
|
||||||
_specifications = specifications;
|
_specifications = specifications;
|
||||||
_parsingService = parsingService;
|
_parsingService = parsingService;
|
||||||
|
@ -100,13 +100,12 @@ namespace NzbDrone.Core.DecisionEngine
|
||||||
yield return decision;
|
yield return decision;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria = null)
|
private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria = null)
|
||||||
{
|
{
|
||||||
var reasons = _specifications.Select(c => EvaluateSpec(c, remoteEpisode, searchCriteria))
|
var reasons = _specifications.Select(c => EvaluateSpec(c, remoteEpisode, searchCriteria))
|
||||||
.Where(c => !string.IsNullOrWhiteSpace(c));
|
.Where(c => !string.IsNullOrWhiteSpace(c));
|
||||||
|
|
||||||
return new DownloadDecision(remoteEpisode, reasons.ToArray());
|
return new DownloadDecision(remoteEpisode, reasons.ToArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.DecisionEngine
|
namespace NzbDrone.Core.DecisionEngine
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
|
|
||||||
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
|
||||||
{
|
{
|
||||||
|
|
||||||
_logger.Trace("Beginning size check for: {0}", subject);
|
_logger.Trace("Beginning size check for: {0}", subject);
|
||||||
|
|
||||||
var quality = subject.ParsedEpisodeInfo.Quality.Quality;
|
var quality = subject.ParsedEpisodeInfo.Quality.Quality;
|
||||||
|
@ -45,21 +44,17 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
}
|
}
|
||||||
|
|
||||||
var qualityDefinition = _qualityDefinitionService.Get(quality);
|
var qualityDefinition = _qualityDefinitionService.Get(quality);
|
||||||
|
var minSize = qualityDefinition.MinSize.Megabytes();
|
||||||
|
|
||||||
|
//Multiply maxSize by Series.Runtime
|
||||||
|
minSize = minSize * subject.Series.Runtime * subject.Episodes.Count;
|
||||||
|
|
||||||
|
//If the parsed size is smaller than minSize we don't want it
|
||||||
|
if (subject.Release.Size < minSize)
|
||||||
{
|
{
|
||||||
var minSize = qualityDefinition.MinSize.Megabytes();
|
_logger.Trace("Item: {0}, Size: {1} is smaller than minimum allowed size ({2}), rejecting.", subject, subject.Release.Size, minSize);
|
||||||
|
return false;
|
||||||
//Multiply maxSize by Series.Runtime
|
|
||||||
minSize = minSize * subject.Series.Runtime * subject.Episodes.Count;
|
|
||||||
|
|
||||||
//If the parsed size is smaller than minSize we don't want it
|
|
||||||
if (subject.Release.Size < minSize)
|
|
||||||
{
|
|
||||||
_logger.Trace("Item: {0}, Size: {1} is smaller than minimum allowed size ({2}), rejecting.", subject, subject.Release.Size, minSize);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qualityDefinition.MaxSize == 0)
|
if (qualityDefinition.MaxSize == 0)
|
||||||
{
|
{
|
||||||
_logger.Trace("Max size is 0 (unlimited) - skipping check.");
|
_logger.Trace("Max size is 0 (unlimited) - skipping check.");
|
||||||
|
@ -84,10 +79,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Trace("Item: {0}, meets size constraints.", subject);
|
_logger.Trace("Item: {0}, meets size constraints.", subject);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace NzbDrone.Core.Jobs
|
||||||
|
|
||||||
public ScheduledTask GetDefinition(Type type)
|
public ScheduledTask GetDefinition(Type type)
|
||||||
{
|
{
|
||||||
return Query.Single(c => c.TypeName == type.FullName);
|
return Query.Where(c => c.TypeName == type.FullName).Single();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLastExecutionTime(int id, DateTime executionTime)
|
public void SetLastExecutionTime(int id, DateTime executionTime)
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Metadata.Files
|
||||||
|
|
||||||
public MetadataFile FindByPath(string path)
|
public MetadataFile FindByPath(string path)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(c => c.RelativePath == path);
|
return Query.Where(c => c.RelativePath == path).SingleOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.Qualities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Query.Single(q => (int)q.Quality == qualityId);
|
return Query.Where(q => (int) q.Quality == qualityId).Single();
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException e)
|
catch (InvalidOperationException e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,22 +37,31 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
public Episode Find(int seriesId, int season, int episodeNumber)
|
public Episode Find(int seriesId, int season, int episodeNumber)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == season && s.EpisodeNumber == episodeNumber);
|
return Query.Where(s => s.SeriesId == seriesId)
|
||||||
|
.AndWhere(s => s.SeasonNumber == season)
|
||||||
|
.AndWhere(s => s.EpisodeNumber == episodeNumber)
|
||||||
|
.SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Episode Find(int seriesId, int absoluteEpisodeNumber)
|
public Episode Find(int seriesId, int absoluteEpisodeNumber)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.AbsoluteEpisodeNumber == absoluteEpisodeNumber);
|
return Query.Where(s => s.SeriesId == seriesId)
|
||||||
|
.AndWhere(s => s.AbsoluteEpisodeNumber == absoluteEpisodeNumber)
|
||||||
|
.SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Episode Get(int seriesId, String date)
|
public Episode Get(int seriesId, String date)
|
||||||
{
|
{
|
||||||
return Query.Single(s => s.SeriesId == seriesId && s.AirDate == date);
|
return Query.Where(s => s.SeriesId == seriesId)
|
||||||
|
.AndWhere(s => s.AirDate == date)
|
||||||
|
.Single();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Episode Find(int seriesId, String date)
|
public Episode Find(int seriesId, String date)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.AirDate == date);
|
return Query.Where(s => s.SeriesId == seriesId)
|
||||||
|
.AndWhere(s => s.AirDate == date)
|
||||||
|
.SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Episode> GetEpisodes(int seriesId)
|
public List<Episode> GetEpisodes(int seriesId)
|
||||||
|
@ -62,7 +71,9 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
public List<Episode> GetEpisodes(int seriesId, int seasonNumber)
|
public List<Episode> GetEpisodes(int seriesId, int seasonNumber)
|
||||||
{
|
{
|
||||||
return Query.Where(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber).ToList();
|
return Query.Where(s => s.SeriesId == seriesId)
|
||||||
|
.AndWhere(s => s.SeasonNumber == seasonNumber)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Episode> GetEpisodeByFileId(int fileId)
|
public List<Episode> GetEpisodeByFileId(int fileId)
|
||||||
|
@ -88,10 +99,12 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
public Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
public Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SceneSeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber);
|
return Query.Where(s => s.SeriesId == seriesId)
|
||||||
|
.AndWhere(s => s.SceneSeasonNumber == seasonNumber)
|
||||||
|
.AndWhere(s => s.SceneEpisodeNumber == episodeNumber)
|
||||||
|
.SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate)
|
public List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
||||||
|
|
|
@ -103,7 +103,6 @@ namespace NzbDrone.Core.Tv
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec)
|
public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec)
|
||||||
{
|
{
|
||||||
var episodeResult = _episodeRepository.EpisodesWithoutFiles(pagingSpec, false);
|
var episodeResult = _episodeRepository.EpisodesWithoutFiles(pagingSpec, false);
|
||||||
|
@ -139,7 +138,6 @@ namespace NzbDrone.Core.Tv
|
||||||
var episode = GetEpisode(episodeId);
|
var episode = GetEpisode(episodeId);
|
||||||
var seasonEpisodes = GetEpisodesBySeason(episode.SeriesId, episode.SeasonNumber);
|
var seasonEpisodes = GetEpisodesBySeason(episode.SeriesId, episode.SeasonNumber);
|
||||||
|
|
||||||
|
|
||||||
//Ensure that this is either the first episode
|
//Ensure that this is either the first episode
|
||||||
//or is the last episode in a season that has 10 or more episodes
|
//or is the last episode in a season that has 10 or more episodes
|
||||||
if (seasonEpisodes.First().EpisodeNumber == episode.EpisodeNumber || (seasonEpisodes.Count() >= 10 && seasonEpisodes.Last().EpisodeNumber == episode.EpisodeNumber))
|
if (seasonEpisodes.First().EpisodeNumber == episode.EpisodeNumber || (seasonEpisodes.Count() >= 10 && seasonEpisodes.Last().EpisodeNumber == episode.EpisodeNumber))
|
||||||
|
|
|
@ -25,28 +25,34 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
public bool SeriesPathExists(string path)
|
public bool SeriesPathExists(string path)
|
||||||
{
|
{
|
||||||
return Query.Any(c => c.Path == path);
|
return Query.Where(c => c.Path == path).Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Series FindByTitle(string cleanTitle)
|
public Series FindByTitle(string cleanTitle)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase));
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
||||||
|
|
||||||
|
return Query.Where(s => s.CleanTitle == cleanTitle)
|
||||||
|
.SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Series FindByTitle(string cleanTitle, int year)
|
public Series FindByTitle(string cleanTitle, int year)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase) &&
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
||||||
s.Year == year);
|
|
||||||
|
return Query.Where(s => s.CleanTitle == cleanTitle)
|
||||||
|
.AndWhere(s => s.Year == year)
|
||||||
|
.SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Series FindByTvdbId(int tvdbId)
|
public Series FindByTvdbId(int tvdbId)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
|
return Query.Where(s => s.TvdbId == tvdbId).SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Series FindByTvRageId(int tvRageId)
|
public Series FindByTvRageId(int tvRageId)
|
||||||
{
|
{
|
||||||
return Query.SingleOrDefault(s => s.TvRageId.Equals(tvRageId));
|
return Query.Where(s => s.TvRageId == tvRageId).SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
|
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
|
||||||
|
|
|
@ -98,8 +98,6 @@ namespace NzbDrone.Core.Tv
|
||||||
return FindByTvdbId(tvdbId.Value);
|
return FindByTvdbId(tvdbId.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clean = Parser.Parser.CleanSeriesTitle(title);
|
|
||||||
|
|
||||||
return _seriesRepository.FindByTitle(Parser.Parser.CleanSeriesTitle(title));
|
return _seriesRepository.FindByTitle(Parser.Parser.CleanSeriesTitle(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue