mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using EntityFrameworkCore.Projectables;
|
||||||
using Kyoo.Abstractions.Models.Attributes;
|
using Kyoo.Abstractions.Models.Attributes;
|
||||||
using Kyoo.Utils;
|
using Kyoo.Utils;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -142,6 +144,18 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[LoadableRelation] public ICollection<Collection>? Collections { get; set; }
|
[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 />
|
/// <inheritdoc />
|
||||||
public void OnMerge(object merged)
|
public void OnMerge(object merged)
|
||||||
{
|
{
|
||||||
|
@ -253,6 +253,8 @@ namespace Kyoo.Postgresql
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Show>()
|
||||||
|
.Ignore(x => x.FirstEpisode);
|
||||||
modelBuilder.Entity<Episode>()
|
modelBuilder.Entity<Episode>()
|
||||||
.Ignore(x => x.PreviousEpisode)
|
.Ignore(x => x.PreviousEpisode)
|
||||||
.Ignore(x => x.NextEpisode);
|
.Ignore(x => x.NextEpisode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user