aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Item/OrderMapper.cs
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-06-07 22:37:34 +0200
committerShadowghost <Ghost_of_Stone@web.de>2026-06-07 23:06:14 +0200
commit9ea3f458863f1f1db1a2eb56d2a5799834a64ec9 (patch)
treebc0827443cae86c5655fe4da22ed9a1c0f9bc1f3 /Jellyfin.Server.Implementations/Item/OrderMapper.cs
parente64cc73f881fc9def52f9e362a5094dbdbbcb7fb (diff)
Make resume queries version-aware
Diffstat (limited to 'Jellyfin.Server.Implementations/Item/OrderMapper.cs')
-rw-r--r--Jellyfin.Server.Implementations/Item/OrderMapper.cs5
1 files changed, 4 insertions, 1 deletions
diff --git a/Jellyfin.Server.Implementations/Item/OrderMapper.cs b/Jellyfin.Server.Implementations/Item/OrderMapper.cs
index d327b218a9..eeeeda8193 100644
--- a/Jellyfin.Server.Implementations/Item/OrderMapper.cs
+++ b/Jellyfin.Server.Implementations/Item/OrderMapper.cs
@@ -34,7 +34,10 @@ public static class OrderMapper
(ItemSortBy.AirTime, _) => e => e.SortName,
(ItemSortBy.Runtime, _) => e => e.RunTimeTicks,
(ItemSortBy.Random, _) => e => EF.Functions.Random(),
- (ItemSortBy.DatePlayed, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).FirstOrDefault()!.LastPlayedDate,
+ (ItemSortBy.DatePlayed, not null) => e =>
+ jellyfinDbContext.UserData
+ .Where(w => w.UserId == query.User.Id && (w.ItemId == e.Id || w.Item!.PrimaryVersionId == e.Id))
+ .Max(f => f.LastPlayedDate),
(ItemSortBy.PlayCount, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).FirstOrDefault()!.PlayCount,
(ItemSortBy.IsFavoriteOrLiked, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).Select(f => (bool?)f.IsFavorite).FirstOrDefault() ?? false,
(ItemSortBy.IsFolder, _) => e => e.IsFolder,