mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add a firstEpisode field on the backend
This commit is contained in:
parent
c4f1e420f8
commit
e12a1d369d
@ -19,6 +19,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Kyoo.Abstractions.Models.Attributes;
|
||||
using Kyoo.Utils;
|
||||
using Newtonsoft.Json;
|
||||
@ -142,6 +144,18 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
[LoadableRelation] public ICollection<Collection>? Collections { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The first episode of this show.
|
||||
/// </summary>
|
||||
[Projectable(UseMemberBody = nameof(_FirstEpisode), OnlyOnInclude = true)]
|
||||
[LoadableRelation] public Episode? FirstEpisode { get; set; }
|
||||
|
||||
private Episode? _FirstEpisode => Episodes!
|
||||
.OrderBy(x => x.AbsoluteNumber)
|
||||
.ThenBy(x => x.SeasonNumber)
|
||||
.ThenBy(x => x.EpisodeNumber)
|
||||
.FirstOrDefault();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnMerge(object merged)
|
||||
{
|
||||
|
@ -253,6 +253,8 @@ namespace Kyoo.Postgresql
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Show>()
|
||||
.Ignore(x => x.FirstEpisode);
|
||||
modelBuilder.Entity<Episode>()
|
||||
.Ignore(x => x.PreviousEpisode)
|
||||
.Ignore(x => x.NextEpisode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user