Fix next episodes on continue watching

This commit is contained in:
Zoe Roux 2023-12-08 03:07:55 +01:00
parent 0c9711baea
commit a54311c53f

View File

@ -330,9 +330,19 @@ public class WatchStatusRepository : IWatchStatusRepository
.IgnoreQueryFilters() .IgnoreQueryFilters()
.Where(x => x.ShowId == showId) .Where(x => x.ShowId == showId)
.OrderByDescending(x => x.AbsoluteNumber) .OrderByDescending(x => x.AbsoluteNumber)
.OrderByDescending(x => x.SeasonNumber) .ThenByDescending(x => x.SeasonNumber)
.OrderByDescending(x => x.EpisodeNumber) .ThenByDescending(x => x.EpisodeNumber)
.Select(x => new { x.Id, Status = x.Watched!.First(x => x.UserId == userId) }) .Select(
x =>
new
{
x.Id,
x.AbsoluteNumber,
x.SeasonNumber,
x.EpisodeNumber,
Status = x.Watched!.First(x => x.UserId == userId)
}
)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
x => x =>
x.Status.Status == WatchStatus.Completed x.Status.Status == WatchStatus.Completed
@ -346,9 +356,19 @@ public class WatchStatusRepository : IWatchStatusRepository
.Episodes .Episodes
.IgnoreQueryFilters() .IgnoreQueryFilters()
.Where(x => x.ShowId == showId) .Where(x => x.ShowId == showId)
.OrderByDescending(x => x.AbsoluteNumber) .OrderBy(x => x.AbsoluteNumber)
.OrderByDescending(x => x.SeasonNumber) .ThenBy(x => x.SeasonNumber)
.OrderByDescending(x => x.EpisodeNumber) .ThenBy(x => x.EpisodeNumber)
.Where(
x =>
cursor == null
|| x.AbsoluteNumber > cursor.AbsoluteNumber
|| x.SeasonNumber > cursor.SeasonNumber
|| (
x.SeasonNumber == cursor.SeasonNumber
&& x.EpisodeNumber > cursor.EpisodeNumber
)
)
.Select( .Select(
x => x =>
new new