Adds independent metadata and artwork enrichment

Splits the single combined enrichment phase of the media library scan into
independent, modular jobs, so that the metadata and the artwork of a book
are enriched separately and only when their respective triggers fire.

- Adds the MediaContributorRoleCategory enum (Other first, then Author,
  Translator, Illustrator, Publisher and Narrator) and makes the role
  category canonical, so that roles describing the same kind of
  contribution are never treated as distinct.
- Realizes the media contributor bounded context: a MediaContributor is a
  person, unique by display name, without a role. The role moves to the
  per-work participation (BookContributors), so that a single contributor
  can play multiple roles. Contributors are created and linked by the
  metadata enrichment job, and exposed to subsequent jobs.
- Makes the Book aggregate pure: the enrichment tracking state (metadata
  status, providers, timestamps and covers) no longer lives on the domain
  aggregate, but stays in the Books table, managed directly by the jobs.
- Models artwork generically as a BookArtwork child table (type, ordinal,
  content hash, status and provider), so that each piece of artwork is
  tracked independently and a change of one does not require the others to
  be re-fetched.
- Splits the scan DAG into ResultsSave, ProviderConfigurationInvalidation,
  MetadataEnrichment and ArtworkEnrichment jobs. The invalidation job
  fingerprints the provider configuration of a library and resets the
  enrichment state of the affected channel when it changed. The artwork job
  resolves the missing artwork, hashing it to detect identical covers and
  skip re-copying. Content-changed books are reset by the results save job.
- Deletes the book and its stored artwork when the file disappears from the
  library.
- Adds the migration creating the new tables, backfilling the existing
  covers into the artwork table, and adding the configuration fingerprints.
- Localizes the new scan job stages, and fixes the invalidation job wiping
  the library content locations by persisting the fingerprints through the
  change tracker instead of the repository update action.
This commit is contained in:
BinaryAlley committed 2026-08-27 14:41:49 +03:00
1 parent 4ee2976806
commit 565fe68239
98 files changed
+5845 -630

No files matched your search

@@ -0,0 +1,73 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
#endregion
namespace Lumina.DataAccess.Common.Configuration;
/// <summary>
/// Configures the entity mapping for the <see cref="BookArtworkEntity"/> entity.
/// </summary>
public class BookArtworkConfiguration : IEntityTypeConfiguration<BookArtworkEntity>
{
/// <summary>
/// Configures the <see cref="BookArtworkEntity"/> entity.
/// </summary>
/// <param name="builder">The builder to be used to configure the entity.</param>
public void Configure(EntityTypeBuilder<BookArtworkEntity> builder)
{
builder.ToTable("BookArtwork");
builder.HasKey(bookArtwork => bookArtwork.Id);
builder.Property(bookArtwork => bookArtwork.Id)
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
.HasColumnOrder(0);
builder.Property(bookArtwork => bookArtwork.BookId)
.IsRequired()
.HasColumnOrder(1);
builder.Property(bookArtwork => bookArtwork.ArtworkType)
.IsRequired()
.HasConversion<string>()
.HasMaxLength(50)
.HasColumnOrder(2);
builder.Property(bookArtwork => bookArtwork.Ordinal)
.IsRequired()
.HasColumnOrder(3);
builder.Property(bookArtwork => bookArtwork.FileName)
.HasMaxLength(2048)
.HasColumnOrder(4);
builder.Property(bookArtwork => bookArtwork.ContentHash)
.HasColumnOrder(5);
builder.Property(bookArtwork => bookArtwork.Status)
.IsRequired()
.HasConversion<string>()
.HasMaxLength(20)
.HasColumnOrder(6);
builder.Property(bookArtwork => bookArtwork.Provider)
.HasMaxLength(100)
.HasColumnOrder(7);
builder.Property(bookArtwork => bookArtwork.LastUpdateUtc)
.HasColumnOrder(8);
// audit
builder.Property(bookArtwork => bookArtwork.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(9);
builder.Property(bookArtwork => bookArtwork.CreatedBy)
.IsRequired()
.HasColumnOrder(10);
builder.Property(bookArtwork => bookArtwork.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(11);
builder.Property(bookArtwork => bookArtwork.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(12);
builder.HasIndex(bookArtwork => new { bookArtwork.BookId, bookArtwork.ArtworkType, bookArtwork.Ordinal })
.IsUnique();
builder.HasIndex(bookArtwork => bookArtwork.Status);
}
}
@@ -152,27 +152,15 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
builder.Property(book => book.UpdatedOnUtc)
.HasColumnOrder(31);
//builder.HasMany<ContributorIdModel>()
//.WithMany()
//.UsingEntity<Dictionary<string, object>>(
// "BookContributors",
// j => j.HasOne<ContributorIdModel>().WithMany().HasForeignKey("ContributorId"),
// j => j.HasOne<BookModel>().WithMany().HasForeignKey("BookId"),
// j =>
// {
// j.HasKey("BookId", "ContributorId");
// j.ToTable("BookContributors");
// });
builder.HasMany(book => book.BookContributors)
.WithOne()
.HasForeignKey(bookContributor => bookContributor.BookId)
.OnDelete(DeleteBehavior.Cascade);
//builder.OwnsMany(book => book.ContributorIds, ownedBuilder =>
//{
// ownedBuilder.ToTable("BookContributors");
// ownedBuilder.WithOwner().HasForeignKey("BookId");
// ownedBuilder.Property(c => c.Id)
// .HasColumnName("ContributorId")
// .HasColumnType("uniqueidentifier");
// ownedBuilder.HasKey("BookId", "Id"); // Use the actual property name 'Id' here
//});
builder.HasMany(book => book.BookArtwork)
.WithOne()
.HasForeignKey(bookArtwork => bookArtwork.BookId)
.OnDelete(DeleteBehavior.Cascade);
builder.OwnsMany(book => book.Ratings, ratingBuilder =>
{
@@ -241,13 +229,3 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
builder.HasIndex(book => new { book.LibraryId, book.MetadataStatus });
}
}
//public class ContributorConfiguration : IEntityTypeConfiguration<ContributorIdModel>
//{
// public void Configure(EntityTypeBuilder<ContributorIdModel> builder)
// {
// builder.ToTable("Contributors");
// builder.HasKey(c => c.Id);
// builder.Property(c => c.Id).ValueGeneratedNever();
// }
//}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
#endregion
namespace Lumina.DataAccess.Common.Configuration;
/// <summary>
/// Configures the entity mapping for the <see cref="BookContributorEntity"/> entity.
/// </summary>
public class BookContributorConfiguration : IEntityTypeConfiguration<BookContributorEntity>
{
/// <summary>
/// Configures the <see cref="BookContributorEntity"/> entity.
/// </summary>
/// <param name="builder">The builder to be used to configure the entity.</param>
public void Configure(EntityTypeBuilder<BookContributorEntity> builder)
{
builder.ToTable("BookContributors");
builder.HasKey(bookContributor => bookContributor.Id);
builder.Property(bookContributor => bookContributor.Id)
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
.HasColumnOrder(0);
builder.Property(bookContributor => bookContributor.BookId)
.IsRequired()
.HasColumnOrder(1);
builder.Property(bookContributor => bookContributor.MediaContributorId)
.IsRequired()
.HasColumnOrder(2);
builder.Property(bookContributor => bookContributor.RoleName)
.IsRequired()
.HasMaxLength(100)
.HasColumnOrder(3);
builder.Property(bookContributor => bookContributor.RoleCategory)
.IsRequired()
.HasConversion<string>()
.HasMaxLength(50)
.HasColumnOrder(4);
// audit
builder.Property(bookContributor => bookContributor.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(5);
builder.Property(bookContributor => bookContributor.CreatedBy)
.IsRequired()
.HasColumnOrder(6);
builder.Property(bookContributor => bookContributor.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(7);
builder.Property(bookContributor => bookContributor.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(8);
builder.HasIndex(bookContributor => new { bookContributor.BookId, bookContributor.MediaContributorId });
builder.HasIndex(bookContributor => bookContributor.MediaContributorId);
}
}
@@ -56,6 +56,16 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
builder.Property(library => library.ShouldSkipUnchangedDirectoriesDuringScan)
.HasColumnOrder(8);
builder.Property(library => library.MetadataProvidersConfigurationFingerprint)
.HasMaxLength(64)
.HasDefaultValue(null)
.HasColumnOrder(9);
builder.Property(library => library.ArtworkProvidersConfigurationFingerprint)
.HasMaxLength(64)
.HasDefaultValue(null)
.HasColumnOrder(10);
// one user with many libraries
builder.HasOne(library => library.User)
.WithMany(user => user.Libraries)
@@ -88,18 +98,18 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
// audit
builder.Property(library => library.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(9);
.HasColumnOrder(11);
builder.Property(library => library.CreatedBy)
.IsRequired()
.HasColumnOrder(10);
.HasColumnOrder(12);
builder.Property(library => library.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(11);
.HasColumnOrder(13);
builder.Property(library => library.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(12);
.HasColumnOrder(14);
}
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
#endregion
namespace Lumina.DataAccess.Common.Configuration;
/// <summary>
/// Configures the entity mapping for the <see cref="MediaContributorEntity"/> entity.
/// </summary>
public class MediaContributorConfiguration : IEntityTypeConfiguration<MediaContributorEntity>
{
/// <summary>
/// Configures the <see cref="MediaContributorEntity"/> entity.
/// </summary>
/// <param name="builder">The builder to be used to configure the entity.</param>
public void Configure(EntityTypeBuilder<MediaContributorEntity> builder)
{
builder.ToTable("MediaContributors");
builder.HasKey(contributor => contributor.Id);
builder.Property(contributor => contributor.Id)
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
.HasColumnOrder(0);
builder.Property(contributor => contributor.DisplayName)
.IsRequired()
.HasMaxLength(255)
.UseCollation("NOCASE")
.HasColumnOrder(1);
builder.Property(contributor => contributor.LegalName)
.HasMaxLength(255)
.HasColumnOrder(2);
builder.Property(contributor => contributor.Biography)
.HasMaxLength(2000)
.HasColumnOrder(3);
builder.Property(contributor => contributor.DateOfBirth)
.HasColumnOrder(4);
builder.Property(contributor => contributor.DateOfDeath)
.HasColumnOrder(5);
// audit
builder.Property(contributor => contributor.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(6);
builder.Property(contributor => contributor.CreatedBy)
.IsRequired()
.HasColumnOrder(7);
builder.Property(contributor => contributor.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(8);
builder.Property(contributor => contributor.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(9);
builder.HasIndex(contributor => contributor.DisplayName)
.IsUnique();
}
}
@@ -0,0 +1,256 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
/// <inheritdoc />
public partial class AddsIndependentMetadataAndArtworkEnrichment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "UpdatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 13)
.OldAnnotation("Relational:ColumnOrder", 11);
migrationBuilder.AlterColumn<Guid>(
name: "UpdatedBy",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(Guid),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 14)
.OldAnnotation("Relational:ColumnOrder", 12);
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 11)
.OldAnnotation("Relational:ColumnOrder", 9);
migrationBuilder.AlterColumn<Guid>(
name: "CreatedBy",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(Guid),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 12)
.OldAnnotation("Relational:ColumnOrder", 10);
migrationBuilder.AddColumn<string>(
name: "ArtworkProvidersConfigurationFingerprint",
table: "Libraries",
type: "TEXT",
maxLength: 64,
nullable: true)
.Annotation("Relational:ColumnOrder", 10);
migrationBuilder.AddColumn<string>(
name: "MetadataProvidersConfigurationFingerprint",
table: "Libraries",
type: "TEXT",
maxLength: 64,
nullable: true)
.Annotation("Relational:ColumnOrder", 9);
migrationBuilder.CreateTable(
name: "BookArtwork",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
BookId = table.Column<Guid>(type: "TEXT", nullable: false),
ArtworkType = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Ordinal = table.Column<int>(type: "INTEGER", nullable: false),
FileName = table.Column<string>(type: "TEXT", maxLength: 2048, nullable: true),
ContentHash = table.Column<ulong>(type: "INTEGER", nullable: false),
Status = table.Column<string>(type: "TEXT", maxLength: 20, nullable: false),
Provider = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
LastUpdateUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BookArtwork", x => x.Id);
table.ForeignKey(
name: "FK_BookArtwork_Books_BookId",
column: x => x.BookId,
principalTable: "Books",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// backfill the artwork of the books that already had a cover, so that the stored covers are preserved as enriched cover artwork
// before the CoverImagePath column is dropped
migrationBuilder.Sql("""
INSERT INTO BookArtwork (Id, BookId, ArtworkType, Ordinal, FileName, ContentHash, Status, Provider, LastUpdateUtc, CreatedOnUtc, CreatedBy, UpdatedOnUtc, UpdatedBy)
SELECT lower(hex(randomblob(16))), Id, 'Cover', 0, CoverImagePath, 0, 'Enriched', NULL, NULL, datetime('now'), '00000000-0000-0000-0000-000000000000', NULL, NULL
FROM Books
WHERE CoverImagePath IS NOT NULL;
""");
migrationBuilder.DropColumn(
name: "CoverImagePath",
table: "Books");
migrationBuilder.CreateTable(
name: "BookContributors",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
BookId = table.Column<Guid>(type: "TEXT", nullable: false),
MediaContributorId = table.Column<Guid>(type: "TEXT", nullable: false),
RoleName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
RoleCategory = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BookContributors", x => x.Id);
table.ForeignKey(
name: "FK_BookContributors_Books_BookId",
column: x => x.BookId,
principalTable: "Books",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MediaContributors",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
DisplayName = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false, collation: "NOCASE"),
LegalName = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
Biography = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true),
DateOfBirth = table.Column<DateOnly>(type: "TEXT", nullable: true),
DateOfDeath = table.Column<DateOnly>(type: "TEXT", nullable: true),
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaContributors", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_BookArtwork_BookId_ArtworkType_Ordinal",
table: "BookArtwork",
columns: new[] { "BookId", "ArtworkType", "Ordinal" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_BookArtwork_Status",
table: "BookArtwork",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_BookContributors_BookId_MediaContributorId",
table: "BookContributors",
columns: new[] { "BookId", "MediaContributorId" });
migrationBuilder.CreateIndex(
name: "IX_BookContributors_MediaContributorId",
table: "BookContributors",
column: "MediaContributorId");
migrationBuilder.CreateIndex(
name: "IX_MediaContributors_DisplayName",
table: "MediaContributors",
column: "DisplayName",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BookArtwork");
migrationBuilder.DropTable(
name: "BookContributors");
migrationBuilder.DropTable(
name: "MediaContributors");
migrationBuilder.DropColumn(
name: "ArtworkProvidersConfigurationFingerprint",
table: "Libraries");
migrationBuilder.DropColumn(
name: "MetadataProvidersConfigurationFingerprint",
table: "Libraries");
migrationBuilder.AlterColumn<DateTime>(
name: "UpdatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 11)
.OldAnnotation("Relational:ColumnOrder", 13);
migrationBuilder.AlterColumn<Guid>(
name: "UpdatedBy",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(Guid),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 12)
.OldAnnotation("Relational:ColumnOrder", 14);
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 9)
.OldAnnotation("Relational:ColumnOrder", 11);
migrationBuilder.AlterColumn<Guid>(
name: "CreatedBy",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(Guid),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 10)
.OldAnnotation("Relational:ColumnOrder", 12);
migrationBuilder.AddColumn<string>(
name: "CoverImagePath",
table: "Books",
type: "TEXT",
nullable: true);
}
}
}
@@ -239,6 +239,112 @@ namespace Lumina.DataAccess.Common.Migrations
b.ToTable("Tags", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaContributors.BookContributorEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("BookId")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.Property<Guid>("MediaContributorId")
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<string>("RoleCategory")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<string>("RoleName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(8);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(7);
b.HasKey("Id");
b.HasIndex("MediaContributorId");
b.HasIndex("BookId", "MediaContributorId");
b.ToTable("BookContributors", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaContributors.MediaContributorEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<string>("Biography")
.HasMaxLength(2000)
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(7);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<DateOnly?>("DateOfBirth")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateOnly?>("DateOfDeath")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasColumnOrder(1)
.UseCollation("NOCASE");
b.Property<string>("LegalName")
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(9);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(8);
b.HasKey("Id");
b.HasIndex("DisplayName")
.IsUnique();
b.ToTable("MediaContributors", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b =>
{
b.Property<Guid>("LibraryId")
@@ -270,6 +376,11 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<string>("ArtworkProvidersConfigurationFingerprint")
.HasMaxLength(64)
.HasColumnType("TEXT")
.HasColumnOrder(10);
b.Property<bool>("CanDownloadMetadataFromWeb")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
@@ -283,11 +394,11 @@ namespace Lumina.DataAccess.Common.Migrations
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(10);
.HasColumnOrder(12);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(9);
.HasColumnOrder(11);
b.Property<bool>("IsEnabled")
.ValueGeneratedOnAdd()
@@ -304,6 +415,11 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<string>("MetadataProvidersConfigurationFingerprint")
.HasMaxLength(64)
.HasColumnType("TEXT")
.HasColumnOrder(9);
b.Property<bool>("ShouldSaveMetadataInMediaDirectories")
.HasColumnType("INTEGER")
.HasColumnOrder(7);
@@ -320,11 +436,11 @@ namespace Lumina.DataAccess.Common.Migrations
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(12);
.HasColumnOrder(14);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(11);
.HasColumnOrder(13);
b.Property<Guid>("UserId")
.HasColumnType("TEXT");
@@ -515,6 +631,76 @@ namespace Lumina.DataAccess.Common.Migrations
b.ToTable("LibraryScanStagingResults", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookArtworkEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<string>("ArtworkType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<Guid>("BookId")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<ulong>("ContentHash")
.HasColumnType("INTEGER")
.HasColumnOrder(5);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(10);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(9);
b.Property<string>("FileName")
.HasMaxLength(2048)
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateTime?>("LastUpdateUtc")
.HasColumnType("TEXT")
.HasColumnOrder(8);
b.Property<int>("Ordinal")
.HasColumnType("INTEGER")
.HasColumnOrder(3);
b.Property<string>("Provider")
.HasMaxLength(100)
.HasColumnType("TEXT")
.HasColumnOrder(7);
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(12);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(11);
b.HasKey("Id");
b.HasIndex("Status");
b.HasIndex("BookId", "ArtworkType", "Ordinal")
.IsUnique();
b.ToTable("BookArtwork", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
{
b.Property<Guid>("Id")
@@ -535,9 +721,6 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(28);
b.Property<string>("CoverImagePath")
.HasColumnType("TEXT");
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(33);
@@ -1139,6 +1322,15 @@ namespace Lumina.DataAccess.Common.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaContributors.BookContributorEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
.WithMany("BookContributors")
.HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", null)
@@ -1236,6 +1428,15 @@ namespace Lumina.DataAccess.Common.Migrations
.IsRequired();
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookArtworkEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
.WithMany("BookArtwork")
.HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
{
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 =>
@@ -1339,6 +1540,13 @@ namespace Lumina.DataAccess.Common.Migrations
b.Navigation("LibraryScanResults");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
{
b.Navigation("BookArtwork");
b.Navigation("BookContributors");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
{
b.Navigation("Libraries");
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Application.Common.DataAccess.Repositories.Books;
using Lumina.Application.Common.DTO.Filtering;
@@ -11,6 +12,8 @@ using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.Common;
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@@ -84,6 +87,7 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.BookArtwork)
.FirstOrDefaultAsync(book => book.Id == id, cancellationToken).ConfigureAwait(false);
}
@@ -98,6 +102,7 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.BookArtwork)
.ToListAsync(cancellationToken).ConfigureAwait(false);
}
@@ -118,6 +123,7 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.Ratings)
.Include(book => book.BookArtwork)
.AsNoTracking();
// books should always be retrieved only per owning libraries
@@ -180,6 +186,7 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.BookArtwork)
.Where(book => book.LibraryId == libraryId)
.ToListAsync(cancellationToken).ConfigureAwait(false);
}
@@ -197,6 +204,7 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.BookArtwork)
.FirstOrDefaultAsync(book => book.LibraryId == libraryId && book.Path == path, cancellationToken).ConfigureAwait(false);
}
@@ -215,6 +223,7 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.BookContributors)
.Where(book => book.LibraryId == libraryId
&& book.MetadataStatus != MetadataStatus.Enriched
&& (lastPath == null || book.Path.CompareTo(lastPath) > 0))
@@ -235,6 +244,148 @@ internal sealed class BookRepository : IBookRepository
.CountAsync(book => book.LibraryId == libraryId && book.MetadataStatus != MetadataStatus.Enriched, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Gets a page of the books of the media library identified by <paramref name="libraryId"/> that need their artwork resolved,
/// meaning they lack at least one required piece of artwork with an enriched status, ordered by path, using keyset pagination.
/// </summary>
/// <param name="libraryId">The Id of the media library whose books are retrieved.</param>
/// <param name="lastPath">The path of the last retrieved book, used for keyset pagination. Pass <see langword="null"/> to get the first page.</param>
/// <param name="pageSize">The maximum number of books to retrieve.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a page of books needing their artwork resolved, or an error.</returns>
public async Task<Result<IReadOnlyList<BookEntity>>> GetBooksNeedingArtworkAsync(Guid libraryId, string? lastPath, int pageSize, CancellationToken cancellationToken)
{
return await _luminaDbContext.Books
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.BookArtwork)
.Where(book => book.LibraryId == libraryId
&& !book.BookArtwork.Any(artwork => artwork.ArtworkType == ArtworkType.Cover && artwork.Status == ArtworkStatus.Enriched)
&& (lastPath == null || book.Path.CompareTo(lastPath) > 0))
.OrderBy(book => book.Path)
.Take(pageSize)
.ToListAsync(cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Gets the number of books of the media library identified by <paramref name="libraryId"/> that need their artwork resolved.
/// </summary>
/// <param name="libraryId">The Id of the media library whose books are counted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the number of books needing their artwork resolved, or an error.</returns>
public async Task<Result<int>> GetBooksNeedingArtworkCountAsync(Guid libraryId, CancellationToken cancellationToken)
{
return await _luminaDbContext.Books
.CountAsync(book => book.LibraryId == libraryId
&& !book.BookArtwork.Any(artwork => artwork.ArtworkType == ArtworkType.Cover && artwork.Status == ArtworkStatus.Enriched), cancellationToken)
.ConfigureAwait(false);
}
/// <summary>
/// Resets the enrichment state of the books stored at the provided <paramref name="paths"/> in the media library identified by
/// <paramref name="libraryId"/>, so that they are re-enriched, because their content changed since the last scan.
/// </summary>
/// <param name="libraryId">The Id of the media library whose books are reset.</param>
/// <param name="paths">The file system paths of the books whose enrichment state is reset.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<Result<Updated>> ResetEnrichmentStateForPathsAsync(Guid libraryId, IReadOnlyCollection<string> paths, CancellationToken cancellationToken)
{
await _luminaDbContext.Books
.Where(book => book.LibraryId == libraryId && paths.Contains(book.Path))
.ExecuteUpdateAsync(setters => setters.SetProperty(book => book.MetadataStatus, MetadataStatus.Pending), cancellationToken)
.ConfigureAwait(false);
await _luminaDbContext.Set<BookArtworkEntity>()
.Where(artwork => _luminaDbContext.Books.Any(book => book.Id == artwork.BookId && book.LibraryId == libraryId && paths.Contains(book.Path)))
.ExecuteUpdateAsync(setters => setters.SetProperty(artwork => artwork.Status, ArtworkStatus.Pending), cancellationToken)
.ConfigureAwait(false);
return Result.Updated;
}
/// <summary>
/// Resets the metadata enrichment status of all the books of the media library identified by <paramref name="libraryId"/>,
/// so that they are re-enriched, because the metadata provider configuration of the library changed.
/// </summary>
/// <param name="libraryId">The Id of the media library whose books are reset.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<Result<Updated>> ResetMetadataStatusForLibraryAsync(Guid libraryId, CancellationToken cancellationToken)
{
await _luminaDbContext.Books
.Where(book => book.LibraryId == libraryId)
.ExecuteUpdateAsync(setters => setters.SetProperty(book => book.MetadataStatus, MetadataStatus.Pending), cancellationToken)
.ConfigureAwait(false);
return Result.Updated;
}
/// <summary>
/// Resets the artwork status of all the artwork of the books of the media library identified by <paramref name="libraryId"/>,
/// so that they are re-resolved, because the artwork provider configuration of the library changed.
/// </summary>
/// <param name="libraryId">The Id of the media library whose artwork is reset.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<Result<Updated>> ResetArtworkStatusForLibraryAsync(Guid libraryId, CancellationToken cancellationToken)
{
await _luminaDbContext.Set<BookArtworkEntity>()
.Where(artwork => _luminaDbContext.Books.Any(book => book.Id == artwork.BookId && book.LibraryId == libraryId))
.ExecuteUpdateAsync(setters => setters.SetProperty(artwork => artwork.Status, ArtworkStatus.Pending), cancellationToken)
.ConfigureAwait(false);
return Result.Updated;
}
/// <summary>
/// Gets the display names of the author of the books identified by the provided <paramref name="bookIds"/>,
/// keyed by the Id of the book, or <see langword="null"/> when a book has no author.
/// </summary>
/// <param name="bookIds">The unique identifiers of the books whose authors are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the display names of the authors of the books, keyed by book Id, or an error.</returns>
public async Task<Result<IReadOnlyDictionary<Guid, string?>>> GetAuthorsDisplayNamesByBookIdsAsync(IReadOnlyCollection<Guid> bookIds, CancellationToken cancellationToken)
{
List<AuthorRow> authorRows = await _luminaDbContext.BookContributors
.Where(bookContributor => bookIds.Contains(bookContributor.BookId) && bookContributor.RoleCategory == MediaContributorRoleCategory.Author)
.Join(_luminaDbContext.MediaContributors,
bookContributor => bookContributor.MediaContributorId,
contributor => contributor.Id,
(bookContributor, contributor) => new AuthorRow(bookContributor.BookId, contributor.DisplayName))
.ToListAsync(cancellationToken)
.ConfigureAwait(false);
return authorRows
.GroupBy(row => row.BookId)
.ToDictionary(group => group.Key, group => (string?)group.Min(row => row.DisplayName));
}
/// <summary>
/// The author row of a book, joining the participation of an author contributor in a book with the display name of the contributor.
/// </summary>
/// <param name="BookId">The Id of the book.</param>
/// <param name="DisplayName">The display name of the author contributor.</param>
private sealed record AuthorRow(Guid BookId, string DisplayName);
/// <summary>
/// Deletes the book identified by <paramref name="bookId"/>.
/// </summary>
/// <param name="bookId">The Id of the book to delete.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<Result<Deleted>> DeleteAsync(Guid bookId, CancellationToken cancellationToken)
{
BookEntity? book = await _luminaDbContext.Books
.FirstOrDefaultAsync(repositoryBook => repositoryBook.Id == bookId, cancellationToken).ConfigureAwait(false);
if (book is null)
return Errors.WrittenContent.BookNotFound;
_luminaDbContext.Books.Remove(book);
return Result.Deleted;
}
/// <summary>
/// Updates a book.
/// </summary>
@@ -145,6 +145,30 @@ internal sealed class LibraryScanStagingResultsRepository : ILibraryScanStagingR
return page.ToList();
}
/// <summary>
/// Gets the paths of the media library scan staging results of the current scan that changed, meaning their content needs to be re-hashed
/// and the books stored at those paths need to be re-enriched, excluding the staging results that are new.
/// </summary>
/// <param name="scanId">The unique identifier of the media library scan whose staging results are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the paths of the changed staging results, or an error.</returns>
public async Task<Result<IReadOnlyList<string>>> GetChangedPathsAsync(Guid scanId, CancellationToken cancellationToken)
{
await using SqliteConnection connection = await OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
const string GET_CHANGED_PATHS_SQL = """
SELECT Path
FROM LibraryScanStagingResults
WHERE LibraryScanId = @scanId
AND NeedsRehash = 1
AND IsNew = 0;
""";
CommandDefinition command = new(GET_CHANGED_PATHS_SQL, new { scanId }, cancellationToken: cancellationToken);
IEnumerable<string> paths = await connection.QueryAsync<string>(command).ConfigureAwait(false);
return paths.ToList();
}
/// <summary>
/// Updates the content hashes of the provided media library scan staging results.
/// </summary>
@@ -0,0 +1,89 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
using Lumina.Application.Common.DataAccess.Repositories.MediaContributors;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.Common.Primitives;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.DataAccess.Core.Repositories.MediaContributors;
/// <summary>
/// Repository for media contributors.
/// </summary>
internal sealed class MediaContributorRepository : IMediaContributorRepository
{
private readonly LuminaDbContext _luminaDbContext;
/// <summary>
/// Initializes a new instance of the <see cref="MediaContributorRepository"/> class.
/// </summary>
/// <param name="luminaDbContext">Injected Entity Framework DbContext.</param>
public MediaContributorRepository(LuminaDbContext luminaDbContext)
{
_luminaDbContext = luminaDbContext;
}
/// <summary>
/// Adds a new media contributor.
/// </summary>
/// <param name="contributor">The media contributor to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<Result<Created>> InsertAsync(MediaContributorEntity contributor, CancellationToken cancellationToken)
{
_luminaDbContext.MediaContributors.Add(contributor);
return Result.Created;
}
/// <summary>
/// Gets the media contributor whose display name matches the provided <paramref name="displayName"/>, or creates and inserts a new one
/// when no contributor with that name exists yet, guaranteeing a single contributor per person.
/// </summary>
/// <param name="displayName">The name by which the contributor is popularly known.</param>
/// <param name="legalName">The optional legal name of the contributor.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the existing or newly created <see cref="MediaContributorEntity"/>, or an error.</returns>
public async Task<Result<MediaContributorEntity>> FindOrCreateByDisplayNameAsync(string displayName, string? legalName, CancellationToken cancellationToken)
{
// the comparison is case-insensitive, so that "Stephen King" and "stephen king" are never treated as distinct contributors
string normalizedDisplayName = displayName.ToLowerInvariant();
MediaContributorEntity? existingContributor = await _luminaDbContext.MediaContributors
.FirstOrDefaultAsync(contributor => contributor.DisplayName.ToLower() == normalizedDisplayName, cancellationToken)
.ConfigureAwait(false);
if (existingContributor is not null)
return existingContributor;
MediaContributorEntity contributor = new()
{
Id = Guid.NewGuid(),
DisplayName = displayName,
LegalName = legalName,
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.Empty,
UpdatedBy = null
};
_luminaDbContext.MediaContributors.Add(contributor);
return contributor;
}
/// <summary>
/// Gets the media contributors identified by the provided <paramref name="ids"/>.
/// </summary>
/// <param name="ids">The unique identifiers of the media contributors to retrieve.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the retrieved <see cref="MediaContributorEntity"/>s, or an error.</returns>
public async Task<Result<IReadOnlyList<MediaContributorEntity>>> GetByIdsAsync(IReadOnlyCollection<Guid> ids, CancellationToken cancellationToken)
{
return await _luminaDbContext.MediaContributors
.Where(contributor => ids.Contains(contributor.Id))
.ToListAsync(cancellationToken)
.ConfigureAwait(false);
}
}
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Application.Common.DataAccess.Entities.Plugins;
@@ -35,6 +36,8 @@ public class LuminaDbContext : DbContext
public virtual DbSet<LibraryMetadataProviderConfigurationEntity> LibraryMetadataProviderConfigurations { get; set; } = null!;
public virtual DbSet<LibraryArtworkProviderConfigurationEntity> LibraryArtworkProviderConfigurations { get; set; } = null!;
public virtual DbSet<ThemeEntity> Themes { get; set; } = null!;
public virtual DbSet<MediaContributorEntity> MediaContributors { get; set; } = null!;
public virtual DbSet<BookContributorEntity> BookContributors { get; set; } = null!;
/// <summary>
/// Initializes a new instance of the <see cref="LuminaDbContext"/> class.
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Repositories.Authorization;
using Lumina.Application.Common.DataAccess.Repositories.Books;
using Lumina.Application.Common.DataAccess.Repositories.MediaContributors;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
using Lumina.Application.Common.DataAccess.Repositories.Themes;
@@ -9,6 +10,7 @@ using Lumina.Application.Common.DataAccess.UoW;
using Lumina.DataAccess.Core.Repositories.Authorization;
using Lumina.DataAccess.Core.Repositories.Books;
using Lumina.DataAccess.Core.Repositories.Libraries;
using Lumina.DataAccess.Core.Repositories.MediaContributors;
using Lumina.DataAccess.Core.Repositories.Plugins;
using Lumina.DataAccess.Core.Repositories.Themes;
using Lumina.DataAccess.Core.Repositories.Users;
@@ -33,6 +35,7 @@ public class UnitOfWork : IUnitOfWork, IDisposable
private IRoleRepository? _roleRepository;
private IUserRoleRepository? _userRoleRepository;
private IBookRepository? _bookRepository;
private IMediaContributorRepository? _mediaContributorRepository;
private IDirectoryScanFingerprintRepository? _directoryScanFingerprintRepository;
private ILibraryRepository? _libraryRepository;
private ILibraryScanRepository? _libraryScanRepository;
@@ -105,6 +108,15 @@ public class UnitOfWork : IUnitOfWork, IDisposable
}
}
public IMediaContributorRepository MediaContributorRepository
{
get
{
_mediaContributorRepository ??= new MediaContributorRepository(_luminaDbContext);
return _mediaContributorRepository;
}
}
/// <summary>
/// Gets the directory scan fingerprint repository.
/// </summary>