More Metadata Stuff (#3537)
This commit is contained in:
parent
8d3dcc637e
commit
53b13da0c9
34 changed files with 4123 additions and 129 deletions
|
@ -204,11 +204,15 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
|||
.HasForeignKey(smp => smp.PersonId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.Entity<SeriesMetadataPeople>()
|
||||
.Property(b => b.OrderWeight)
|
||||
.HasDefaultValue(0);
|
||||
|
||||
builder.Entity<MetadataSettings>()
|
||||
.Property(x => x.AgeRatingMappings)
|
||||
.HasConversion(
|
||||
v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
|
||||
v => JsonSerializer.Deserialize<Dictionary<string, AgeRating>>(v, JsonSerializerOptions.Default)
|
||||
v => JsonSerializer.Deserialize<Dictionary<string, AgeRating>>(v, JsonSerializerOptions.Default) ?? new Dictionary<string, AgeRating>()
|
||||
);
|
||||
|
||||
// Ensure blacklist is stored as a JSON array
|
||||
|
@ -216,13 +220,19 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
|||
.Property(x => x.Blacklist)
|
||||
.HasConversion(
|
||||
v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
|
||||
v => JsonSerializer.Deserialize<List<string>>(v, JsonSerializerOptions.Default)
|
||||
v => JsonSerializer.Deserialize<List<string>>(v, JsonSerializerOptions.Default) ?? new List<string>()
|
||||
);
|
||||
builder.Entity<MetadataSettings>()
|
||||
.Property(x => x.Whitelist)
|
||||
.HasConversion(
|
||||
v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
|
||||
v => JsonSerializer.Deserialize<List<string>>(v, JsonSerializerOptions.Default)
|
||||
v => JsonSerializer.Deserialize<List<string>>(v, JsonSerializerOptions.Default) ?? new List<string>()
|
||||
);
|
||||
builder.Entity<MetadataSettings>()
|
||||
.Property(x => x.Overrides)
|
||||
.HasConversion(
|
||||
v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
|
||||
v => JsonSerializer.Deserialize<List<MetadataSettingField>>(v, JsonSerializerOptions.Default) ?? new List<MetadataSettingField>()
|
||||
);
|
||||
|
||||
// Configure one-to-many relationship
|
||||
|
@ -235,6 +245,9 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
|||
builder.Entity<MetadataSettings>()
|
||||
.Property(b => b.Enabled)
|
||||
.HasDefaultValue(true);
|
||||
builder.Entity<MetadataSettings>()
|
||||
.Property(b => b.EnableCoverImage)
|
||||
.HasDefaultValue(true);
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
|
|
@ -29,10 +29,18 @@ public static class ManualMigrateBlacklistTableToSeries
|
|||
.Include(s => s.Series.ExternalSeriesMetadata)
|
||||
.Select(s => s.Series)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var series in blacklistedSeries)
|
||||
{
|
||||
series.IsBlacklisted = true;
|
||||
series.ExternalSeriesMetadata ??= new ExternalSeriesMetadata() { SeriesId = series.Id };
|
||||
|
||||
if (series.ExternalSeriesMetadata.AniListId > 0)
|
||||
{
|
||||
series.IsBlacklisted = false;
|
||||
logger.LogInformation("{SeriesName} was in Blacklist table, but has valid AniList Id, not blacklisting", series.Name);
|
||||
}
|
||||
|
||||
context.Series.Entry(series).State = EntityState.Modified;
|
||||
}
|
||||
// Remove everything in SeriesBlacklist (it will be removed in another migration)
|
||||
|
|
3398
API/Data/Migrations/20250208200843_MoreMetadtaSettings.Designer.cs
generated
Normal file
3398
API/Data/Migrations/20250208200843_MoreMetadtaSettings.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
61
API/Data/Migrations/20250208200843_MoreMetadtaSettings.cs
Normal file
61
API/Data/Migrations/20250208200843_MoreMetadtaSettings.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MoreMetadtaSettings : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "KavitaPlusConnection",
|
||||
table: "SeriesMetadataPeople",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "OrderWeight",
|
||||
table: "SeriesMetadataPeople",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "EnableCoverImage",
|
||||
table: "MetadataSettings",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Overrides",
|
||||
table: "MetadataSettings",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "KavitaPlusConnection",
|
||||
table: "SeriesMetadataPeople");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "OrderWeight",
|
||||
table: "SeriesMetadataPeople");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EnableCoverImage",
|
||||
table: "MetadataSettings");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Overrides",
|
||||
table: "MetadataSettings");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1652,6 +1652,11 @@ namespace API.Data.Migrations
|
|||
b.Property<string>("Blacklist")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("EnableCoverImage")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(true);
|
||||
|
||||
b.Property<bool>("EnableGenres")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
@ -1684,10 +1689,13 @@ namespace API.Data.Migrations
|
|||
b.Property<bool>("FirstLastPeopleNaming")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Overrides")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.PrimitiveCollection<string>("PersonRoles")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.PrimitiveCollection<string>("Whitelist")
|
||||
b.Property<string>("Whitelist")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
@ -2114,6 +2122,14 @@ namespace API.Data.Migrations
|
|||
b.Property<int>("Role")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("KavitaPlusConnection")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("OrderWeight")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(0);
|
||||
|
||||
b.HasKey("SeriesMetadataId", "PersonId", "Role");
|
||||
|
||||
b.HasIndex("PersonId");
|
||||
|
|
|
@ -225,6 +225,7 @@ public class ExternalSeriesMetadataRepository : IExternalSeriesMetadataRepositor
|
|||
{
|
||||
return await _context.Series
|
||||
.Include(s => s.Library)
|
||||
.Include(s => s.ExternalSeriesMetadata)
|
||||
.Where(s => !ExternalMetadataService.NonEligibleLibraryTypes.Contains(s.Library.Type))
|
||||
.FilterMatchState(filter.MatchStateOption)
|
||||
.OrderBy(s => s.NormalizedName)
|
||||
|
|
|
@ -309,6 +309,7 @@ public static class Seed
|
|||
EnableGenres = true,
|
||||
EnableLocalizedName = false,
|
||||
FirstLastPeopleNaming = true,
|
||||
EnableCoverImage = true,
|
||||
PersonRoles = [PersonRole.Writer, PersonRole.CoverArtist, PersonRole.Character]
|
||||
};
|
||||
await context.MetadataSettings.AddAsync(existing);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue