Skip to content

Commit

Permalink
Fix previous episode when an absolute number is null
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Dec 6, 2023
1 parent a43d54e commit bf831db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions back/src/Kyoo.Abstractions/Models/Resources/Episode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ or pe.season_number < "this".season_number
or (pe.season_number = "this".season_number
and e.episode_number < "this".episode_number))
order by
pe.absolute_number desc,
pe.absolute_number desc nulls last,
pe.season_number desc,
pe.episode_number desc
limit 1
Expand All @@ -193,7 +193,8 @@ limit 1
public Episode? PreviousEpisode { get; set; }

private Episode? _PreviousEpisode => Show!.Episodes!
.OrderByDescending(x => x.AbsoluteNumber)
.OrderBy(x => x.AbsoluteNumber == null)
.ThenByDescending(x => x.AbsoluteNumber)
.ThenByDescending(x => x.SeasonNumber)
.ThenByDescending(x => x.EpisodeNumber)
.FirstOrDefault(x =>
Expand Down

0 comments on commit bf831db

Please sign in to comment.