mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Hotfix next/previous episodes causing a 500
This commit is contained in:
parent
86427cf6ef
commit
7e0e359f46
@ -19,7 +19,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using JetBrains.Annotations;
|
||||
using Kyoo.Abstractions.Controllers;
|
||||
using Kyoo.Abstractions.Models.Attributes;
|
||||
@ -155,13 +157,35 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <summary>
|
||||
/// The previous episode that should be seen before viewing this one.
|
||||
/// </summary>
|
||||
[Projectable(UseMemberBody = nameof(_PreviousEpisode))]
|
||||
[LoadableRelation] public Episode? PreviousEpisode { get; set; }
|
||||
|
||||
private Episode? _PreviousEpisode => Show!.Episodes!
|
||||
.OrderByDescending(x => x.AbsoluteNumber)
|
||||
.ThenByDescending(x => x.SeasonNumber)
|
||||
.ThenByDescending(x => x.EpisodeNumber)
|
||||
.FirstOrDefault(x =>
|
||||
x.AbsoluteNumber < AbsoluteNumber
|
||||
|| x.SeasonNumber < SeasonNumber
|
||||
|| (x.SeasonNumber == SeasonNumber && x.EpisodeNumber < EpisodeNumber)
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// The next episode to watch after this one.
|
||||
/// </summary>
|
||||
[Projectable(UseMemberBody = nameof(_NextEpisode))]
|
||||
[LoadableRelation] public Episode? NextEpisode { get; set; }
|
||||
|
||||
private Episode? _NextEpisode => Show!.Episodes!
|
||||
.OrderBy(x => x.AbsoluteNumber)
|
||||
.ThenBy(x => x.SeasonNumber)
|
||||
.ThenBy(x => x.EpisodeNumber)
|
||||
.FirstOrDefault(x =>
|
||||
x.AbsoluteNumber > AbsoluteNumber
|
||||
|| x.SeasonNumber > SeasonNumber
|
||||
|| (x.SeasonNumber == SeasonNumber && x.EpisodeNumber > EpisodeNumber)
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Links to watch this episode.
|
||||
/// </summary>
|
||||
|
@ -110,7 +110,6 @@ namespace Kyoo.Abstractions.Models
|
||||
|
||||
/// <summary>
|
||||
/// The Studio that made this show.
|
||||
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
|
||||
/// </summary>
|
||||
[LoadableRelation(nameof(StudioID))][EditableRelation] public Studio? Studio { get; set; }
|
||||
|
||||
|
@ -73,7 +73,6 @@ namespace Kyoo.Abstractions.Models
|
||||
|
||||
/// <summary>
|
||||
/// The show that contains this season.
|
||||
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
|
||||
/// </summary>
|
||||
[LoadableRelation(nameof(ShowId))] public Show? Show { get; set; }
|
||||
|
||||
|
@ -113,7 +113,6 @@ namespace Kyoo.Abstractions.Models
|
||||
|
||||
/// <summary>
|
||||
/// The Studio that made this show.
|
||||
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
|
||||
/// </summary>
|
||||
[LoadableRelation(nameof(StudioId))][EditableRelation] public Studio? Studio { get; set; }
|
||||
|
||||
|
@ -273,7 +273,9 @@ namespace Kyoo.Core.Controllers
|
||||
{
|
||||
if (include == null)
|
||||
return query;
|
||||
foreach (string field in include.Fields)
|
||||
foreach (string field in include.Fields
|
||||
// TODO: Remove this hotfix
|
||||
.Where(x => x != "NextEpisode" && x != "PreviousEpisode"))
|
||||
query = query.Include(field);
|
||||
return query;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user