Fixed: Performance issues when processing results from indexers (RSS/Search)

pull/6/head
Mark McDowall 11 years ago
parent 0a837be9ff
commit 78dacf6850

@ -21,9 +21,7 @@ namespace NzbDrone.Core.Configuration
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.Linq;
using System.Linq.Expressions;
using System.Security.Cryptography.X509Certificates;
using Marr.Data;
using Marr.Data.QGen;
using NzbDrone.Core.Datastore.Events;
@ -74,7 +73,7 @@ namespace NzbDrone.Core.Datastore
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)
{

@ -23,7 +23,7 @@ namespace NzbDrone.Core.DecisionEngine
private readonly IParsingService _parsingService;
private readonly Logger _logger;
public DownloadDecisionMaker(IEnumerable<IRejectWithReason> specifications, IParsingService parsingService, Logger logger)
public DownloadDecisionMaker(IEnumerable<IDecisionEngineSpecification> specifications, IParsingService parsingService, Logger logger)
{
_specifications = specifications;
_parsingService = parsingService;
@ -100,7 +100,6 @@ namespace NzbDrone.Core.DecisionEngine
yield return decision;
}
}
}
private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria = null)

@ -1,6 +1,5 @@
using NLog;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.DecisionEngine
{

@ -27,7 +27,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
_logger.Trace("Beginning size check for: {0}", subject);
var quality = subject.ParsedEpisodeInfo.Quality.Quality;
@ -45,8 +44,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
var qualityDefinition = _qualityDefinitionService.Get(quality);
{
var minSize = qualityDefinition.MinSize.Megabytes();
//Multiply maxSize by Series.Runtime
@ -58,8 +55,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_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)
{
_logger.Trace("Max size is 0 (unlimited) - skipping check.");
@ -84,10 +79,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
return false;
}
}
_logger.Trace("Item: {0}, meets size constraints.", subject);
return true;
}
}
}

@ -23,7 +23,7 @@ namespace NzbDrone.Core.Jobs
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)

@ -56,7 +56,7 @@ namespace NzbDrone.Core.Metadata.Files
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
{
return Query.Single(q => (int)q.Quality == qualityId);
return Query.Where(q => (int) q.Quality == qualityId).Single();
}
catch (InvalidOperationException e)
{

@ -37,22 +37,31 @@ namespace NzbDrone.Core.Tv
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)
{
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)
{
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)
{
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)
@ -62,7 +71,9 @@ namespace NzbDrone.Core.Tv
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)
@ -88,10 +99,12 @@ namespace NzbDrone.Core.Tv
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)
{
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)
{
var episodeResult = _episodeRepository.EpisodesWithoutFiles(pagingSpec, false);
@ -139,7 +138,6 @@ namespace NzbDrone.Core.Tv
var episode = GetEpisode(episodeId);
var seasonEpisodes = GetEpisodesBySeason(episode.SeriesId, episode.SeasonNumber);
//Ensure that this is either the first episode
//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))

@ -25,28 +25,34 @@ namespace NzbDrone.Core.Tv
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)
{
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)
{
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase) &&
s.Year == year);
cleanTitle = cleanTitle.ToLowerInvariant();
return Query.Where(s => s.CleanTitle == cleanTitle)
.AndWhere(s => s.Year == year)
.SingleOrDefault();
}
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)
{
return Query.SingleOrDefault(s => s.TvRageId.Equals(tvRageId));
return Query.Where(s => s.TvRageId == tvRageId).SingleOrDefault();
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)

@ -98,8 +98,6 @@ namespace NzbDrone.Core.Tv
return FindByTvdbId(tvdbId.Value);
}
var clean = Parser.Parser.CleanSeriesTitle(title);
return _seriesRepository.FindByTitle(Parser.Parser.CleanSeriesTitle(title));
}

Loading…
Cancel
Save