Add episode count in season

This commit is contained in:
Zoe Roux 2023-09-09 20:07:22 +02:00
parent 234d3c9c7c
commit 9b606cf9ac
4 changed files with 13 additions and 1 deletions

View File

@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.1" />
<PackageReference Include="EntityFrameworkCore.Projectables" Version="3.0.4" />
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />

View File

@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
using EntityFrameworkCore.Projectables;
using JetBrains.Annotations;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Attributes;
@ -119,5 +120,13 @@ namespace Kyoo.Abstractions.Models
/// The list of episodes that this season contains.
/// </summary>
[LoadableRelation] public ICollection<Episode>? Episodes { get; set; }
/// <summary>
/// The number of episodes in this season.
/// </summary>
[Projectable(UseMemberBody = nameof(_EpisodeCount))]
public int EpisodeCount { get; set; }
private int _EpisodeCount => Episodes!.Count;
}
}

View File

@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="7.0.2" />
<PackageReference Include="EntityFrameworkCore.Projectables" Version="3.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -87,7 +87,8 @@ namespace Kyoo.Postgresql
["MAXPOOLSIZE"] = "95",
["TIMEOUT"] = "30"
};
x.UseNpgsql(builder.ConnectionString);
x.UseNpgsql(builder.ConnectionString)
.UseProjectables();
if (_environment.IsDevelopment())
x.EnableDetailedErrors().EnableSensitiveDataLogging();
}, ServiceLifetime.Transient);