From 30a52d11aa4749b430c5cbb828bb95066da2260b Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 22 Sep 2024 07:21:53 +0300 Subject: [PATCH] Fixed: Sorting queue by columns Sort allowed keys Co-authored-by: Mark McDowall --- .../Blocklist/BlocklistController.cs | 6 ++--- .../History/HistoryController.cs | 4 +-- .../ImportListExclusionController.cs | 4 +-- src/Sonarr.Api.V3/Queue/QueueController.cs | 26 ++++++++++++++++++- src/Sonarr.Api.V3/Wanted/CutoffController.cs | 4 +-- src/Sonarr.Api.V3/Wanted/MissingController.cs | 4 +-- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs b/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs index d29b1a86e..87fdc9e02 100644 --- a/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs +++ b/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs @@ -33,10 +33,10 @@ namespace Sonarr.Api.V3.Blocklist var pagingSpec = pagingResource.MapToPagingSpec( new HashSet(StringComparer.OrdinalIgnoreCase) { - "series.sortTitle", - "sourceTitle", "date", - "indexer" + "indexer", + "series.sortTitle", + "sourceTitle" }, "date", SortDirection.Descending); diff --git a/src/Sonarr.Api.V3/History/HistoryController.cs b/src/Sonarr.Api.V3/History/HistoryController.cs index b0810113e..517098f4e 100644 --- a/src/Sonarr.Api.V3/History/HistoryController.cs +++ b/src/Sonarr.Api.V3/History/HistoryController.cs @@ -68,8 +68,8 @@ namespace Sonarr.Api.V3.History var pagingSpec = pagingResource.MapToPagingSpec( new HashSet(StringComparer.OrdinalIgnoreCase) { - "series.sortTitle", - "date" + "date", + "series.sortTitle" }, "date", SortDirection.Descending); diff --git a/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs b/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs index 30bd035b4..7102fca41 100644 --- a/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs +++ b/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs @@ -51,8 +51,8 @@ namespace Sonarr.Api.V3.ImportLists new HashSet(StringComparer.OrdinalIgnoreCase) { "id", - "tvdbId", - "title" + "title", + "tvdbId" }, "id", SortDirection.Descending); diff --git a/src/Sonarr.Api.V3/Queue/QueueController.cs b/src/Sonarr.Api.V3/Queue/QueueController.cs index 34315de1e..96917878e 100644 --- a/src/Sonarr.Api.V3/Queue/QueueController.cs +++ b/src/Sonarr.Api.V3/Queue/QueueController.cs @@ -139,7 +139,31 @@ namespace Sonarr.Api.V3.Queue public PagingResource GetQueue([FromQuery] PagingRequestResource paging, bool includeUnknownSeriesItems = false, bool includeSeries = false, bool includeEpisode = false, [FromQuery] int[] seriesIds = null, DownloadProtocol? protocol = null, [FromQuery] int[] languages = null, int? quality = null) { var pagingResource = new PagingResource(paging); - var pagingSpec = pagingResource.MapToPagingSpec(null, "timeleft", SortDirection.Ascending); + var pagingSpec = pagingResource.MapToPagingSpec( + new HashSet(StringComparer.OrdinalIgnoreCase) + { + "added", + "downloadClient", + "episode", + "episode.airDateUtc", + "episode.title", + "episodes.airDateUtc", + "episodes.title", + "estimatedCompletionTime", + "indexer", + "language", + "languages", + "progress", + "protocol", + "quality", + "series.sortTitle", + "size", + "status", + "timeleft", + "title" + }, + "timeleft", + SortDirection.Ascending); return pagingSpec.ApplyToPage((spec) => GetQueue(spec, seriesIds?.ToHashSet(), protocol, languages?.ToHashSet(), quality, includeUnknownSeriesItems), (q) => MapToResource(q, includeSeries, includeEpisode)); } diff --git a/src/Sonarr.Api.V3/Wanted/CutoffController.cs b/src/Sonarr.Api.V3/Wanted/CutoffController.cs index 8da4dc597..4df880dc7 100644 --- a/src/Sonarr.Api.V3/Wanted/CutoffController.cs +++ b/src/Sonarr.Api.V3/Wanted/CutoffController.cs @@ -36,9 +36,9 @@ namespace Sonarr.Api.V3.Wanted var pagingSpec = pagingResource.MapToPagingSpec( new HashSet(StringComparer.OrdinalIgnoreCase) { - "series.sortTitle", "episodes.airDateUtc", - "episodes.lastSearchTime" + "episodes.lastSearchTime", + "series.sortTitle" }, "episodes.airDateUtc", SortDirection.Ascending); diff --git a/src/Sonarr.Api.V3/Wanted/MissingController.cs b/src/Sonarr.Api.V3/Wanted/MissingController.cs index 2c05025c6..bbfde535f 100644 --- a/src/Sonarr.Api.V3/Wanted/MissingController.cs +++ b/src/Sonarr.Api.V3/Wanted/MissingController.cs @@ -32,9 +32,9 @@ namespace Sonarr.Api.V3.Wanted var pagingSpec = pagingResource.MapToPagingSpec( new HashSet(StringComparer.OrdinalIgnoreCase) { - "series.sortTitle", "episodes.airDateUtc", - "episodes.lastSearchTime" + "episodes.lastSearchTime", + "series.sortTitle" }, "episodes.airDateUtc", SortDirection.Ascending);