aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-05-05 17:31:19 +0200
committerShadowghost <Ghost_of_Stone@web.de>2026-05-05 17:31:19 +0200
commit8a43b1c784b7693fa26d56c6eaa875639794d9cf (patch)
treec5bc42f4539bb9051681ff14675e5dce37a5b19e
parent4178e0ebaf2ff7162f474e17e27cd5bbbfafd548 (diff)
Fix rewatch query
-rw-r--r--Jellyfin.Server.Implementations/Item/NextUpService.cs18
1 files changed, 12 insertions, 6 deletions
diff --git a/Jellyfin.Server.Implementations/Item/NextUpService.cs b/Jellyfin.Server.Implementations/Item/NextUpService.cs
index d78e246691..725b4cfaac 100644
--- a/Jellyfin.Server.Implementations/Item/NextUpService.cs
+++ b/Jellyfin.Server.Implementations/Item/NextUpService.cs
@@ -127,15 +127,21 @@ public class NextUpService : INextUpService
.AsNoTracking()
.Where(e => e.Type == episodeTypeName)
.Where(e => e.SeriesPresentationUniqueKey != null && seriesKeys.Contains(e.SeriesPresentationUniqueKey))
- .Where(e => e.ParentIndexNumber != 0)
- .Where(e => e.UserData!.Any(ud => ud.UserId == userId && ud.Played));
+ .Where(e => e.ParentIndexNumber != 0);
lastWatchedByDateBase = _queryHelpers.ApplyAccessFiltering(context, lastWatchedByDateBase, filter);
- // Use lightweight projection + client-side grouping instead of
- // SelectMany+GroupBy+OrderByDescending+FirstOrDefault (correlated subquery).
+ // Use an explicit Join (INNER JOIN) instead of SelectMany on a collection navigation.
+ // SelectMany on UserData with a correlated Where would translate to APPLY,
+ // which SQLite does not support.
var playedWithDates = lastWatchedByDateBase
- .SelectMany(e => e.UserData!.Where(ud => ud.UserId == userId && ud.Played)
- .Select(ud => new { EpisodeId = e.Id, e.SeriesPresentationUniqueKey, ud.LastPlayedDate }))
+ .Join(
+ context.UserData
+ .AsNoTracking()
+ .Where(ud => ud.ItemId != EF.Constant(BaseItemRepository.PlaceholderId))
+ .Where(ud => ud.Played),
+ e => new { UserId = userId, ItemId = e.Id },
+ ud => new { ud.UserId, ud.ItemId },
+ (e, ud) => new { EpisodeId = e.Id, e.SeriesPresentationUniqueKey, ud.LastPlayedDate })
.ToList();
foreach (var group in playedWithDates.GroupBy(x => x.SeriesPresentationUniqueKey))