예제 #1
0
 private SortBuilder <Episode> EpisodesWhereCutoffUnmetQuery(PagingSpec <Episode> pagingSpec, List <QualitiesBelowCutoff> qualitiesBelowCutoff, int startingSeasonNumber)
 {
     return(Query.Join <Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
            .Join <Episode, EpisodeFile>(JoinType.Left, e => e.EpisodeFile, (e, s) => e.EpisodeFileId == s.Id)
            .Where(pagingSpec.FilterExpression)
            .AndWhere(e => e.EpisodeFileId != 0)
            .AndWhere(e => e.SeasonNumber >= startingSeasonNumber)
            .AndWhere(BuildQualityCutoffWhereClause(qualitiesBelowCutoff))
            .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
            .Skip(pagingSpec.PagingOffset())
            .Take(pagingSpec.PageSize));
 }
예제 #2
0
 private SortBuilder <Episode> GetEpisodesWithoutFilesQuery(PagingSpec <Episode> pagingSpec, DateTime currentTime, int startingSeasonNumber)
 {
     return(Query.Join <Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
            .Where(e => e.EpisodeFileId == 0)
            .AndWhere(e => e.SeasonNumber >= startingSeasonNumber)
            .AndWhere(e => e.AirDateUtc <= currentTime)
            .AndWhere(e => e.Monitored)
            .AndWhere(e => e.Series.Monitored)
            .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
            .Skip(pagingSpec.PagingOffset())
            .Take(pagingSpec.PageSize));
 }
예제 #3
0
        public override PagingSpec <History> GetPaged(PagingSpec <History> pagingSpec)
        {
            var pagingQuery = Query.Join <History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id)
                              .Join <History, Episode>(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id)
                              .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
                              .Skip(pagingSpec.PagingOffset())
                              .Take(pagingSpec.PageSize);

            pagingSpec.Records = pagingQuery.ToList();

            //TODO: Use the same query for count and records
            pagingSpec.TotalRecords = Count();

            return(pagingSpec);
        }