From b7dcb80ae9cf566c818f5a78d8f3d4eaaea9875b Mon Sep 17 00:00:00 2001 From: Joe Harvey Date: Sat, 19 May 2018 16:40:25 +1200 Subject: [PATCH] Sort TvRequests by latest request --- src/Ombi.Core/Engine/TvRequestEngine.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index d74b45e5e..ddf84376e 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -142,7 +142,8 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) - .Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync(); + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) + .Skip(position).Take(count).ToListAsync(); // Filter out children @@ -154,7 +155,8 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) - .Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync(); + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) + .Skip(position).Take(count).ToListAsync(); } allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); @@ -172,6 +174,7 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) .Skip(position).Take(count).ToListAsync(); FilterChildren(allRequests, shouldHide); @@ -182,6 +185,7 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) .Skip(position).Take(count).ToListAsync(); }