mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using EntityFrameworkCore.Projectables;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Abstractions.Models.Attributes;
|
using Kyoo.Abstractions.Models.Attributes;
|
||||||
@ -155,13 +157,35 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The previous episode that should be seen before viewing this one.
|
/// The previous episode that should be seen before viewing this one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Projectable(UseMemberBody = nameof(_PreviousEpisode))]
|
||||||
[LoadableRelation] public Episode? PreviousEpisode { get; set; }
|
[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>
|
/// <summary>
|
||||||
/// The next episode to watch after this one.
|
/// The next episode to watch after this one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Projectable(UseMemberBody = nameof(_NextEpisode))]
|
||||||
[LoadableRelation] public Episode? NextEpisode { get; set; }
|
[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>
|
/// <summary>
|
||||||
/// Links to watch this episode.
|
/// Links to watch this episode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -110,7 +110,6 @@ namespace Kyoo.Abstractions.Models
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Studio that made this show.
|
/// The Studio that made this show.
|
||||||
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[LoadableRelation(nameof(StudioID))][EditableRelation] public Studio? Studio { get; set; }
|
[LoadableRelation(nameof(StudioID))][EditableRelation] public Studio? Studio { get; set; }
|
||||||
|
|
||||||
|
@ -73,7 +73,6 @@ namespace Kyoo.Abstractions.Models
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The show that contains this season.
|
/// The show that contains this season.
|
||||||
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[LoadableRelation(nameof(ShowId))] public Show? Show { get; set; }
|
[LoadableRelation(nameof(ShowId))] public Show? Show { get; set; }
|
||||||
|
|
||||||
|
@ -113,7 +113,6 @@ namespace Kyoo.Abstractions.Models
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Studio that made this show.
|
/// The Studio that made this show.
|
||||||
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[LoadableRelation(nameof(StudioId))][EditableRelation] public Studio? Studio { get; set; }
|
[LoadableRelation(nameof(StudioId))][EditableRelation] public Studio? Studio { get; set; }
|
||||||
|
|
||||||
|
@ -273,7 +273,9 @@ namespace Kyoo.Core.Controllers
|
|||||||
{
|
{
|
||||||
if (include == null)
|
if (include == null)
|
||||||
return query;
|
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);
|
query = query.Include(field);
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user