private List <QueueResource> GetQueue() { var includeArtist = Request.GetBooleanQueryParameter("includeArtist"); var includeAlbum = Request.GetBooleanQueryParameter("includeAlbum", true); var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = queue.Concat(pending); var artistIdQuery = Request.Query.ArtistId; var albumIdsQuery = Request.Query.AlbumIds; if (artistIdQuery.HasValue) { return(fullQueue.Where(q => q.Artist?.Id == (int)artistIdQuery).ToResource(includeArtist, includeAlbum)); } if (albumIdsQuery.HasValue) { string albumIdsValue = albumIdsQuery.Value.ToString(); var albumIds = albumIdsValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(e => Convert.ToInt32(e)) .ToList(); return(fullQueue.Where(q => q.Album != null && albumIds.Contains(q.Album.Id)).ToResource(includeArtist, includeAlbum)); } return(fullQueue.ToResource(includeArtist, includeAlbum)); }
private IEnumerable <Core.Queue.Queue> GetQueueItems() { var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); return(queue.Concat(pending)); }
private List <QueueResource> GetQueue() { var includeSeries = Request.GetBooleanQueryParameter("includeSeries"); var includeEpisode = Request.GetBooleanQueryParameter("includeEpisode", true); var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = queue.Concat(pending); var seriesIdQuery = Request.Query.SeriesId; var episodeIdsQuery = Request.Query.EpisodeIds; if (seriesIdQuery.HasValue) { return(fullQueue.Where(q => q.Series?.Id == (int)seriesIdQuery).ToResource(includeSeries, includeEpisode)); } if (episodeIdsQuery.HasValue) { string episodeIdsValue = episodeIdsQuery.Value.ToString(); var episodeIds = episodeIdsValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(e => Convert.ToInt32(e)) .ToList(); return(fullQueue.Where(q => q.Episode != null && episodeIds.Contains(q.Episode.Id)).ToResource(includeSeries, includeEpisode)); } return(fullQueue.ToResource(includeSeries, includeEpisode)); }
private List <QueueResource> GetQueue() { var includeAuthor = Request.GetBooleanQueryParameter("includeAuthor"); var includeBook = Request.GetBooleanQueryParameter("includeBook", true); var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = queue.Concat(pending); var authorIdQuery = Request.Query.AuthorId; var bookIdsQuery = Request.Query.BookIds; if (authorIdQuery.HasValue) { return(fullQueue.Where(q => q.Author?.Id == (int)authorIdQuery).ToResource(includeAuthor, includeBook)); } if (bookIdsQuery.HasValue) { string bookIdsValue = bookIdsQuery.Value.ToString(); var bookIds = bookIdsValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(e => Convert.ToInt32(e)) .ToList(); return(fullQueue.Where(q => q.Book != null && bookIds.Contains(q.Book.Id)).ToResource(includeAuthor, includeBook)); } return(fullQueue.ToResource(includeAuthor, includeBook)); }
public List <QueueResource> GetQueue(int?movieId, bool includeMovie = false) { var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = queue.Concat(pending); if (movieId.HasValue) { return(fullQueue.Where(q => q.Movie?.Id == movieId.Value).ToResource(includeMovie)); } return(fullQueue.ToResource(includeMovie)); }
private List <QueueResource> GetQueue() { var includeMovie = Request.GetBooleanQueryParameter("includeMovie"); var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = queue.Concat(pending); var movieIdQuery = Request.Query.MovieId; if (movieIdQuery.HasValue) { return(fullQueue.Where(q => q.Movie?.Id == (int)movieIdQuery).ToResource(includeMovie)); } return(fullQueue.ToResource(includeMovie)); }
public List <QueueResource> GetQueue(int?authorId, [FromQuery] List <int> bookIds, bool includeAuthor = false, bool includeBook = true) { var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = queue.Concat(pending); if (authorId.HasValue) { return(fullQueue.Where(q => q.Author?.Id == authorId.Value).ToResource(includeAuthor, includeBook)); } if (bookIds.Any()) { return(fullQueue.Where(q => q.Book != null && bookIds.Contains(q.Book.Id)).ToResource(includeAuthor, includeBook)); } return(fullQueue.ToResource(includeAuthor, includeBook)); }
private QueueStatusResource GetQueueStatus() { _broadcastDebounce.Pause(); var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var resource = new QueueStatusResource { TotalCount = queue.Count + pending.Count, Count = queue.Count(q => q.Artist != null) + pending.Count, UnknownCount = queue.Count(q => q.Artist == null), Errors = queue.Any(q => q.Artist != null && q.TrackedDownloadStatus.Equals("Error", StringComparison.InvariantCultureIgnoreCase)), Warnings = queue.Any(q => q.Artist != null && q.TrackedDownloadStatus.Equals("Warning", StringComparison.InvariantCultureIgnoreCase)), UnknownErrors = queue.Any(q => q.Artist == null && q.TrackedDownloadStatus.Equals("Error", StringComparison.InvariantCultureIgnoreCase)), UnknownWarnings = queue.Any(q => q.Artist == null && q.TrackedDownloadStatus.Equals("Warning", StringComparison.InvariantCultureIgnoreCase)) }; _broadcastDebounce.Resume(); return resource; }
private QueueStatusResource GetQueueStatus() { _broadcastDebounce.Pause(); var queue = _queueService.GetQueue(); var pending = _pendingReleaseService.GetPendingQueue(); var resource = new QueueStatusResource { TotalCount = queue.Count + pending.Count, Count = queue.Count(q => q.Artist != null) + pending.Count, UnknownCount = queue.Count(q => q.Artist == null), Errors = queue.Any(q => q.Artist != null && q.TrackedDownloadStatus == TrackedDownloadStatus.Error), Warnings = queue.Any(q => q.Artist != null && q.TrackedDownloadStatus == TrackedDownloadStatus.Warning), UnknownErrors = queue.Any(q => q.Artist == null && q.TrackedDownloadStatus == TrackedDownloadStatus.Error), UnknownWarnings = queue.Any(q => q.Artist == null && q.TrackedDownloadStatus == TrackedDownloadStatus.Warning) }; _broadcastDebounce.Resume(); return(resource); }
private PagingSpec <NzbDrone.Core.Queue.Queue> GetQueue(PagingSpec <NzbDrone.Core.Queue.Queue> pagingSpec, bool includeUnknownArtistItems) { var ascending = pagingSpec.SortDirection == SortDirection.Ascending; var orderByFunc = GetOrderByFunc(pagingSpec); var queue = _queueService.GetQueue(); var filteredQueue = includeUnknownArtistItems ? queue : queue.Where(q => q.Artist != null); var pending = _pendingReleaseService.GetPendingQueue(); var fullQueue = filteredQueue.Concat(pending).ToList(); IOrderedEnumerable <NzbDrone.Core.Queue.Queue> ordered; if (pagingSpec.SortKey == "timeleft") { ordered = ascending ? fullQueue.OrderBy(q => q.Timeleft, new TimeleftComparer()) : fullQueue.OrderByDescending(q => q.Timeleft, new TimeleftComparer()); } else if (pagingSpec.SortKey == "estimatedCompletionTime") { ordered = ascending ? fullQueue.OrderBy(q => q.EstimatedCompletionTime, new EstimatedCompletionTimeComparer()) : fullQueue.OrderByDescending(q => q.EstimatedCompletionTime, new EstimatedCompletionTimeComparer()); } else if (pagingSpec.SortKey == "protocol") { ordered = ascending ? fullQueue.OrderBy(q => q.Protocol) : fullQueue.OrderByDescending(q => q.Protocol); } else if (pagingSpec.SortKey == "indexer") { ordered = ascending ? fullQueue.OrderBy(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase) : fullQueue.OrderByDescending(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase); } else if (pagingSpec.SortKey == "downloadClient") { ordered = ascending ? fullQueue.OrderBy(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase) : fullQueue.OrderByDescending(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase); } else if (pagingSpec.SortKey == "quality") { ordered = ascending ? fullQueue.OrderBy(q => q.Quality, _qualityComparer) : fullQueue.OrderByDescending(q => q.Quality, _qualityComparer); } else { ordered = ascending ? fullQueue.OrderBy(orderByFunc) : fullQueue.OrderByDescending(orderByFunc); } ordered = ordered.ThenByDescending(q => q.Size == 0 ? 0 : 100 - (q.Sizeleft / q.Size * 100)); pagingSpec.Records = ordered.Skip((pagingSpec.Page - 1) * pagingSpec.PageSize).Take(pagingSpec.PageSize).ToList(); pagingSpec.TotalRecords = fullQueue.Count; if (pagingSpec.Records.Empty() && pagingSpec.Page > 1) { pagingSpec.Page = (int)Math.Max(Math.Ceiling((decimal)(pagingSpec.TotalRecords / pagingSpec.PageSize)), 1); pagingSpec.Records = ordered.Skip((pagingSpec.Page - 1) * pagingSpec.PageSize).Take(pagingSpec.PageSize).ToList(); } return(pagingSpec); }