Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
Scanner Performance Improvements (#1774)
Joe Milazzo8a0a2f0961bb
diff --git a/API.Tests/Helpers/GenreHelperTests.cs b/API.Tests/Helpers/GenreHelperTests.csindex 94602ff01..1cda535fd 100644--- a/API.Tests/Helpers/GenreHelperTests.cs+++ b/API.Tests/Helpers/GenreHelperTests.cs@@ -13,13 +13,13 @@ public class GenreHelperTests{var allGenres = new List<Genre>{- DbFactory.Genre("Action", false),- DbFactory.Genre("action", false),- DbFactory.Genre("Sci-fi", false),+ DbFactory.Genre("Action"),+ DbFactory.Genre("action"),+ DbFactory.Genre("Sci-fi"),};var genreAdded = new List<Genre>();- GenreHelper.UpdateGenre(allGenres, new[] {"Action", "Adventure"}, false, genre =>+ GenreHelper.UpdateGenre(allGenres, new[] {"Action", "Adventure"}, genre =>{genreAdded.Add(genre);});@@ -33,19 +33,20 @@ public class GenreHelperTests{var allGenres = new List<Genre>{- DbFactory.Genre("Action", false),- DbFactory.Genre("action", false),- DbFactory.Genre("Sci-fi", false),+ DbFactory.Genre("Action"),+ DbFactory.Genre("action"),+ DbFactory.Genre("Sci-fi"),};var genreAdded = new List<Genre>();- GenreHelper.UpdateGenre(allGenres, new[] {"Action", "Scifi"}, false, genre =>+ GenreHelper.UpdateGenre(allGenres, new[] {"Action", "Scifi"}, genre =>{genreAdded.Add(genre);});Assert.Equal(3, allGenres.Count);+ Assert.Equal(2, genreAdded.Count);}[Fact]@@ -53,49 +54,34 @@ public class GenreHelperTests{var existingGenres = new List<Genre>{- DbFactory.Genre("Action", false),- DbFactory.Genre("action", false),- DbFactory.Genre("Sci-fi", false),+ DbFactory.Genre("Action"),+ DbFactory.Genre("action"),+ DbFactory.Genre("Sci-fi"),};- GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("Action", false));+ GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("Action"));Assert.Equal(3, existingGenres.Count);- GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("action", false));+ GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("action"));Assert.Equal(3, existingGenres.Count);- GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("Shonen", false));+ GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("Shonen"));Assert.Equal(4, existingGenres.Count);}- [Fact]- public void AddGenre_ShouldNotAddSameNameAndExternal()- {- var existingGenres = new List<Genre>- {- DbFactory.Genre("Action", false),- DbFactory.Genre("action", false),- DbFactory.Genre("Sci-fi", false),- };--- GenreHelper.AddGenreIfNotExists(existingGenres, DbFactory.Genre("Action", true));- Assert.Equal(3, existingGenres.Count);- }-[Fact]public void KeepOnlySamePeopleBetweenLists(){var existingGenres = new List<Genre>{- DbFactory.Genre("Action", false),- DbFactory.Genre("Sci-fi", false),+ DbFactory.Genre("Action"),+ DbFactory.Genre("Sci-fi"),};var peopleFromChapters = new List<Genre>{- DbFactory.Genre("Action", false),+ DbFactory.Genre("Action"),};var genreRemoved = new List<Genre>();@@ -113,8 +99,8 @@ public class GenreHelperTests{var existingGenres = new List<Genre>{- DbFactory.Genre("Action", false),- DbFactory.Genre("Sci-fi", false),+ DbFactory.Genre("Action"),+ DbFactory.Genre("Sci-fi"),};var peopleFromChapters = new List<Genre>();diff --git a/API.Tests/Helpers/TagHelperTests.cs b/API.Tests/Helpers/TagHelperTests.csindex 80cebc03b..bc8c1be17 100644--- a/API.Tests/Helpers/TagHelperTests.cs+++ b/API.Tests/Helpers/TagHelperTests.cs@@ -13,13 +13,13 @@ public class TagHelperTests{var allTags = new List<Tag>{- DbFactory.Tag("Action", false),- DbFactory.Tag("action", false),- DbFactory.Tag("Sci-fi", false),+ DbFactory.Tag("Action"),+ DbFactory.Tag("action"),+ DbFactory.Tag("Sci-fi"),};var tagAdded = new List<Tag>();- TagHelper.UpdateTag(allTags, new[] {"Action", "Adventure"}, false, (tag, added) =>+ TagHelper.UpdateTag(allTags, new[] {"Action", "Adventure"}, (tag, added) =>{if (added){@@ -37,14 +37,14 @@ public class TagHelperTests{var allTags = new List<Tag>{- DbFactory.Tag("Action", false),- DbFactory.Tag("action", false),- DbFactory.Tag("Sci-fi", false),+ DbFactory.Tag("Action"),+ DbFactory.Tag("action"),+ DbFactory.Tag("Sci-fi"),};var tagAdded = new List<Tag>();- TagHelper.UpdateTag(allTags, new[] {"Action", "Scifi"}, false, (tag, added) =>+ TagHelper.UpdateTag(allTags, new[] {"Action", "Scifi"}, (tag, added) =>{if (added){@@ -62,49 +62,34 @@ public class TagHelperTests{var existingTags = new List<Tag>{- DbFactory.Tag("Action", false),- DbFactory.Tag("action", false),- DbFactory.Tag("Sci-fi", false),+ DbFactory.Tag("Action"),+ DbFactory.Tag("action"),+ DbFactory.Tag("Sci-fi"),};- TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("Action", false));+ TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("Action"));Assert.Equal(3, existingTags.Count);- TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("action", false));+ TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("action"));Assert.Equal(3, existingTags.Count);- TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("Shonen", false));+ TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("Shonen"));Assert.Equal(4, existingTags.Count);}- [Fact]- public void AddTag_ShouldNotAddSameNameAndExternal()- {- var existingTags = new List<Tag>- {- DbFactory.Tag("Action", false),- DbFactory.Tag("action", false),- DbFactory.Tag("Sci-fi", false),- };--- TagHelper.AddTagIfNotExists(existingTags, DbFactory.Tag("Action", true));- Assert.Equal(3, existingTags.Count);- }-[Fact]public void KeepOnlySamePeopleBetweenLists(){var existingTags = new List<Tag>{- DbFactory.Tag("Action", false),- DbFactory.Tag("Sci-fi", false),+ DbFactory.Tag("Action"),+ DbFactory.Tag("Sci-fi"),};var peopleFromChapters = new List<Tag>{- DbFactory.Tag("Action", false),+ DbFactory.Tag("Action"),};var tagRemoved = new List<Tag>();@@ -122,8 +107,8 @@ public class TagHelperTests{var existingTags = new List<Tag>{- DbFactory.Tag("Action", false),- DbFactory.Tag("Sci-fi", false),+ DbFactory.Tag("Action"),+ DbFactory.Tag("Sci-fi"),};var peopleFromChapters = new List<Tag>();diff --git a/API.Tests/Services/SeriesServiceTests.cs b/API.Tests/Services/SeriesServiceTests.csindex 4d9bbbfdd..e0b24c812 100644--- a/API.Tests/Services/SeriesServiceTests.cs+++ b/API.Tests/Services/SeriesServiceTests.cs@@ -762,7 +762,7 @@ public class SeriesServiceTests : AbstractDbTest},Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())};- var g = DbFactory.Genre("Existing Genre", false);+ var g = DbFactory.Genre("Existing Genre");s.Metadata.Genres = new List<Genre>() {g};_context.Series.Add(s);@@ -918,7 +918,7 @@ public class SeriesServiceTests : AbstractDbTest},Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())};- var g = DbFactory.Genre("Existing Genre", false);+ var g = DbFactory.Genre("Existing Genre");s.Metadata.Genres = new List<Genre>() {g};s.Metadata.GenresLocked = true;_context.Series.Add(s);@@ -1555,5 +1555,11 @@ public class SeriesServiceTests : AbstractDbTestAssert.Null(await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(1));}+ #endregion++ #region UpdateRelatedList+++#endregion}diff --git a/API/Data/DbFactory.cs b/API/Data/DbFactory.csindex 33b6678fd..fc952b051 100644--- a/API/Data/DbFactory.cs+++ b/API/Data/DbFactory.cs@@ -121,23 +121,21 @@ public static class DbFactory};}- public static Genre Genre(string name, bool external)+ public static Genre Genre(string name){return new Genre(){Title = name.Trim().SentenceCase(),NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(name),- ExternalTag = external};}- public static Tag Tag(string name, bool external)+ public static Tag Tag(string name){return new Tag(){Title = name.Trim().SentenceCase(),NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(name),- ExternalTag = external};}diff --git a/API/Data/Migrations/20230203112022_RemoveExternalFromTagAndGenre.Designer.cs b/API/Data/Migrations/20230203112022_RemoveExternalFromTagAndGenre.Designer.csnew file mode 100644index 000000000..008e9690f--- /dev/null+++ b/API/Data/Migrations/20230203112022_RemoveExternalFromTagAndGenre.Designer.cs@@ -0,0 +1,1748 @@+// <auto-generated />+using System;+using API.Data;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Infrastructure;+using Microsoft.EntityFrameworkCore.Migrations;+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;++#nullable disable++namespace API.Data.Migrations+{+ [DbContext(typeof(DataContext))]+ [Migration("20230203112022_RemoveExternalFromTagAndGenre")]+ partial class RemoveExternalFromTagAndGenre+ {+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder.HasAnnotation("ProductVersion", "6.0.10");++ modelBuilder.Entity("API.Entities.AppRole", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("ConcurrencyStamp")+ .IsConcurrencyToken()+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasMaxLength(256)+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedName")+ .HasMaxLength(256)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("NormalizedName")+ .IsUnique()+ .HasDatabaseName("RoleNameIndex");++ b.ToTable("AspNetRoles", (string)null);+ });++ modelBuilder.Entity("API.Entities.AppUser", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("INTEGER");++ b.Property<int>("AgeRestriction")+ .HasColumnType("INTEGER");++ b.Property<bool>("AgeRestrictionIncludeUnknowns")+ .HasColumnType("INTEGER");++ b.Property<string>("ApiKey")+ .HasColumnType("TEXT");++ b.Property<string>("ConcurrencyStamp")+ .IsConcurrencyToken()+ .HasColumnType("TEXT");++ b.Property<string>("ConfirmationToken")+ .HasColumnType("TEXT");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<string>("Email")+ .HasMaxLength(256)+ .HasColumnType("TEXT");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("LastActive")+ .HasColumnType("TEXT");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedEmail")+ .HasMaxLength(256)+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedUserName")+ .HasMaxLength(256)+ .HasColumnType("TEXT");++ b.Property<string>("PasswordHash")+ .HasColumnType("TEXT");++ b.Property<string>("PhoneNumber")+ .HasColumnType("TEXT");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.Property<string>("SecurityStamp")+ .HasColumnType("TEXT");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("INTEGER");++ b.Property<string>("UserName")+ .HasMaxLength(256)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("NormalizedEmail")+ .HasDatabaseName("EmailIndex");++ b.HasIndex("NormalizedUserName")+ .IsUnique()+ .HasDatabaseName("UserNameIndex");++ b.ToTable("AspNetUsers", (string)null);+ });++ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<int>("ChapterId")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<string>("FileName")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<int>("Page")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.Property<int>("VolumeId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("AppUserId");++ b.ToTable("AppUserBookmark");+ });++ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<bool>("AutoCloseMenu")+ .HasColumnType("INTEGER");++ b.Property<string>("BackgroundColor")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT")+ .HasDefaultValue("#000000");++ b.Property<bool>("BlurUnreadSummaries")+ .HasColumnType("INTEGER");++ b.Property<string>("BookReaderFontFamily")+ .HasColumnType("TEXT");++ b.Property<int>("BookReaderFontSize")+ .HasColumnType("INTEGER");++ b.Property<bool>("BookReaderImmersiveMode")+ .HasColumnType("INTEGER");++ b.Property<int>("BookReaderLayoutMode")+ .HasColumnType("INTEGER");++ b.Property<int>("BookReaderLineSpacing")+ .HasColumnType("INTEGER");++ b.Property<int>("BookReaderMargin")+ .HasColumnType("INTEGER");++ b.Property<int>("BookReaderReadingDirection")+ .HasColumnType("INTEGER");++ b.Property<bool>("BookReaderTapToPaginate")+ .HasColumnType("INTEGER");++ b.Property<string>("BookThemeName")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT")+ .HasDefaultValue("Dark");++ b.Property<bool>("EmulateBook")+ .HasColumnType("INTEGER");++ b.Property<int>("GlobalPageLayoutMode")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER")+ .HasDefaultValue(0);++ b.Property<int>("LayoutMode")+ .HasColumnType("INTEGER");++ b.Property<bool>("NoTransitions")+ .HasColumnType("INTEGER");++ b.Property<int>("PageSplitOption")+ .HasColumnType("INTEGER");++ b.Property<bool>("PromptForDownloadSize")+ .HasColumnType("INTEGER");++ b.Property<int>("ReaderMode")+ .HasColumnType("INTEGER");++ b.Property<int>("ReadingDirection")+ .HasColumnType("INTEGER");++ b.Property<int>("ScalingOption")+ .HasColumnType("INTEGER");++ b.Property<bool>("ShowScreenHints")+ .HasColumnType("INTEGER");++ b.Property<bool>("SwipeToPaginate")+ .HasColumnType("INTEGER");++ b.Property<int?>("ThemeId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("AppUserId")+ .IsUnique();++ b.HasIndex("ThemeId");++ b.ToTable("AppUserPreferences");+ });++ modelBuilder.Entity("API.Entities.AppUserProgress", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<string>("BookScrollId")+ .HasColumnType("TEXT");++ b.Property<int>("ChapterId")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<int>("LibraryId")+ .HasColumnType("INTEGER");++ b.Property<int>("PagesRead")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.Property<int>("VolumeId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("AppUserId");++ b.HasIndex("SeriesId");++ b.ToTable("AppUserProgresses");+ });++ modelBuilder.Entity("API.Entities.AppUserRating", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<int>("Rating")+ .HasColumnType("INTEGER");++ b.Property<string>("Review")+ .HasColumnType("TEXT");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("AppUserId");++ b.HasIndex("SeriesId");++ b.ToTable("AppUserRating");+ });++ modelBuilder.Entity("API.Entities.AppUserRole", b =>+ {+ b.Property<int>("UserId")+ .HasColumnType("INTEGER");++ b.Property<int>("RoleId")+ .HasColumnType("INTEGER");++ b.HasKey("UserId", "RoleId");++ b.HasIndex("RoleId");++ b.ToTable("AspNetUserRoles", (string)null);+ });++ modelBuilder.Entity("API.Entities.Chapter", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AgeRating")+ .HasColumnType("INTEGER");++ b.Property<int>("AvgHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<int>("Count")+ .HasColumnType("INTEGER");++ b.Property<string>("CoverImage")+ .HasColumnType("TEXT");++ b.Property<bool>("CoverImageLocked")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<bool>("IsSpecial")+ .HasColumnType("INTEGER");++ b.Property<string>("Language")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<int>("MaxHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<int>("MinHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<string>("Number")+ .HasColumnType("TEXT");++ b.Property<int>("Pages")+ .HasColumnType("INTEGER");++ b.Property<string>("Range")+ .HasColumnType("TEXT");++ b.Property<DateTime>("ReleaseDate")+ .HasColumnType("TEXT");++ b.Property<string>("SeriesGroup")+ .HasColumnType("TEXT");++ b.Property<string>("Summary")+ .HasColumnType("TEXT");++ b.Property<string>("Title")+ .HasColumnType("TEXT");++ b.Property<string>("TitleName")+ .HasColumnType("TEXT");++ b.Property<int>("TotalCount")+ .HasColumnType("INTEGER");++ b.Property<int>("VolumeId")+ .HasColumnType("INTEGER");++ b.Property<long>("WordCount")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("VolumeId");++ b.ToTable("Chapter");+ });++ modelBuilder.Entity("API.Entities.CollectionTag", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("CoverImage")+ .HasColumnType("TEXT");++ b.Property<bool>("CoverImageLocked")+ .HasColumnType("INTEGER");++ b.Property<string>("NormalizedTitle")+ .HasColumnType("TEXT");++ b.Property<bool>("Promoted")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .HasColumnType("INTEGER");++ b.Property<string>("Summary")+ .HasColumnType("TEXT");++ b.Property<string>("Title")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("Id", "Promoted")+ .IsUnique();++ b.ToTable("CollectionTag");+ });++ modelBuilder.Entity("API.Entities.Device", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<string>("EmailAddress")+ .HasColumnType("TEXT");++ b.Property<string>("IpAddress")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastUsed")+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<int>("Platform")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("AppUserId");++ b.ToTable("Device");+ });++ modelBuilder.Entity("API.Entities.FolderPath", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<DateTime>("LastScanned")+ .HasColumnType("TEXT");++ b.Property<int>("LibraryId")+ .HasColumnType("INTEGER");++ b.Property<string>("Path")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("LibraryId");++ b.ToTable("FolderPath");+ });++ modelBuilder.Entity("API.Entities.Genre", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("NormalizedTitle")+ .HasColumnType("TEXT");++ b.Property<string>("Title")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("NormalizedTitle")+ .IsUnique();++ b.ToTable("Genre");+ });++ modelBuilder.Entity("API.Entities.Library", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("CoverImage")+ .HasColumnType("TEXT");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<bool>("FolderWatching")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER")+ .HasDefaultValue(true);++ b.Property<bool>("IncludeInDashboard")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER")+ .HasDefaultValue(true);++ b.Property<bool>("IncludeInRecommended")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER")+ .HasDefaultValue(true);++ b.Property<bool>("IncludeInSearch")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER")+ .HasDefaultValue(true);++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastScanned")+ .HasColumnType("TEXT");++ b.Property<bool>("ManageCollections")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER")+ .HasDefaultValue(true);++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<int>("Type")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.ToTable("Library");+ });++ modelBuilder.Entity("API.Entities.MangaFile", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<long>("Bytes")+ .HasColumnType("INTEGER");++ b.Property<int>("ChapterId")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<string>("Extension")+ .HasColumnType("TEXT");++ b.Property<string>("FilePath")+ .HasColumnType("TEXT");++ b.Property<int>("Format")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("LastFileAnalysis")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<int>("Pages")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("ChapterId");++ b.ToTable("MangaFile");+ });++ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AgeRating")+ .HasColumnType("INTEGER");++ b.Property<bool>("AgeRatingLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("CharacterLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("ColoristLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("CoverArtistLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("EditorLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("GenresLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("InkerLocked")+ .HasColumnType("INTEGER");++ b.Property<string>("Language")+ .HasColumnType("TEXT");++ b.Property<bool>("LanguageLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("LettererLocked")+ .HasColumnType("INTEGER");++ b.Property<int>("MaxCount")+ .HasColumnType("INTEGER");++ b.Property<bool>("PencillerLocked")+ .HasColumnType("INTEGER");++ b.Property<int>("PublicationStatus")+ .HasColumnType("INTEGER");++ b.Property<bool>("PublicationStatusLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("PublisherLocked")+ .HasColumnType("INTEGER");++ b.Property<int>("ReleaseYear")+ .HasColumnType("INTEGER");++ b.Property<bool>("ReleaseYearLocked")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.Property<string>("Summary")+ .HasColumnType("TEXT");++ b.Property<bool>("SummaryLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("TagsLocked")+ .HasColumnType("INTEGER");++ b.Property<int>("TotalCount")+ .HasColumnType("INTEGER");++ b.Property<bool>("TranslatorLocked")+ .HasColumnType("INTEGER");++ b.Property<bool>("WriterLocked")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("SeriesId")+ .IsUnique();++ b.HasIndex("Id", "SeriesId")+ .IsUnique();++ b.ToTable("SeriesMetadata");+ });++ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("RelationKind")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.Property<int>("TargetSeriesId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("SeriesId");++ b.HasIndex("TargetSeriesId");++ b.ToTable("SeriesRelation");+ });++ modelBuilder.Entity("API.Entities.Person", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedName")+ .HasColumnType("TEXT");++ b.Property<int>("Role")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.ToTable("Person");+ });++ modelBuilder.Entity("API.Entities.ReadingList", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AgeRating")+ .HasColumnType("INTEGER");++ b.Property<int>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<string>("CoverImage")+ .HasColumnType("TEXT");++ b.Property<bool>("CoverImageLocked")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedTitle")+ .HasColumnType("TEXT");++ b.Property<bool>("Promoted")+ .HasColumnType("INTEGER");++ b.Property<string>("Summary")+ .HasColumnType("TEXT");++ b.Property<string>("Title")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("AppUserId");++ b.ToTable("ReadingList");+ });++ modelBuilder.Entity("API.Entities.ReadingListItem", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("ChapterId")+ .HasColumnType("INTEGER");++ b.Property<int>("Order")+ .HasColumnType("INTEGER");++ b.Property<int>("ReadingListId")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.Property<int>("VolumeId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("ChapterId");++ b.HasIndex("ReadingListId");++ b.HasIndex("SeriesId");++ b.HasIndex("VolumeId");++ b.ToTable("ReadingListItem");+ });++ modelBuilder.Entity("API.Entities.Series", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int?>("AppUserId")+ .HasColumnType("INTEGER");++ b.Property<int>("AvgHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<string>("CoverImage")+ .HasColumnType("TEXT");++ b.Property<bool>("CoverImageLocked")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<string>("FolderPath")+ .HasColumnType("TEXT");++ b.Property<int>("Format")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("LastChapterAdded")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastFolderScanned")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<int>("LibraryId")+ .HasColumnType("INTEGER");++ b.Property<string>("LocalizedName")+ .HasColumnType("TEXT");++ b.Property<bool>("LocalizedNameLocked")+ .HasColumnType("INTEGER");++ b.Property<int>("MaxHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<int>("MinHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<bool>("NameLocked")+ .HasColumnType("INTEGER");++ b.Property<string>("NormalizedLocalizedName")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedName")+ .HasColumnType("TEXT");++ b.Property<string>("OriginalName")+ .HasColumnType("TEXT");++ b.Property<int>("Pages")+ .HasColumnType("INTEGER");++ b.Property<string>("SortName")+ .HasColumnType("TEXT");++ b.Property<bool>("SortNameLocked")+ .HasColumnType("INTEGER");++ b.Property<long>("WordCount")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("AppUserId");++ b.HasIndex("LibraryId");++ b.ToTable("Series");+ });++ modelBuilder.Entity("API.Entities.ServerSetting", b =>+ {+ b.Property<int>("Key")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.Property<string>("Value")+ .HasColumnType("TEXT");++ b.HasKey("Key");++ b.ToTable("ServerSetting");+ });++ modelBuilder.Entity("API.Entities.ServerStatistics", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<long>("ChapterCount")+ .HasColumnType("INTEGER");++ b.Property<long>("FileCount")+ .HasColumnType("INTEGER");++ b.Property<long>("GenreCount")+ .HasColumnType("INTEGER");++ b.Property<long>("PersonCount")+ .HasColumnType("INTEGER");++ b.Property<long>("SeriesCount")+ .HasColumnType("INTEGER");++ b.Property<long>("TagCount")+ .HasColumnType("INTEGER");++ b.Property<long>("UserCount")+ .HasColumnType("INTEGER");++ b.Property<long>("VolumeCount")+ .HasColumnType("INTEGER");++ b.Property<int>("Year")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.ToTable("ServerStatistics");+ });++ modelBuilder.Entity("API.Entities.SiteTheme", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<string>("FileName")+ .HasColumnType("TEXT");++ b.Property<bool>("IsDefault")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedName")+ .HasColumnType("TEXT");++ b.Property<int>("Provider")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.ToTable("SiteTheme");+ });++ modelBuilder.Entity("API.Entities.Tag", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("NormalizedTitle")+ .HasColumnType("TEXT");++ b.Property<string>("Title")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("NormalizedTitle")+ .IsUnique();++ b.ToTable("Tag");+ });++ modelBuilder.Entity("API.Entities.Volume", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("AvgHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<string>("CoverImage")+ .HasColumnType("TEXT");++ b.Property<DateTime>("Created")+ .HasColumnType("TEXT");++ b.Property<DateTime>("LastModified")+ .HasColumnType("TEXT");++ b.Property<int>("MaxHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<int>("MinHoursToRead")+ .HasColumnType("INTEGER");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<int>("Number")+ .HasColumnType("INTEGER");++ b.Property<int>("Pages")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesId")+ .HasColumnType("INTEGER");++ b.Property<long>("WordCount")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("SeriesId");++ b.ToTable("Volume");+ });++ modelBuilder.Entity("AppUserLibrary", b =>+ {+ b.Property<int>("AppUsersId")+ .HasColumnType("INTEGER");++ b.Property<int>("LibrariesId")+ .HasColumnType("INTEGER");++ b.HasKey("AppUsersId", "LibrariesId");++ b.HasIndex("LibrariesId");++ b.ToTable("AppUserLibrary");+ });++ modelBuilder.Entity("ChapterGenre", b =>+ {+ b.Property<int>("ChaptersId")+ .HasColumnType("INTEGER");++ b.Property<int>("GenresId")+ .HasColumnType("INTEGER");++ b.HasKey("ChaptersId", "GenresId");++ b.HasIndex("GenresId");++ b.ToTable("ChapterGenre");+ });++ modelBuilder.Entity("ChapterPerson", b =>+ {+ b.Property<int>("ChapterMetadatasId")+ .HasColumnType("INTEGER");++ b.Property<int>("PeopleId")+ .HasColumnType("INTEGER");++ b.HasKey("ChapterMetadatasId", "PeopleId");++ b.HasIndex("PeopleId");++ b.ToTable("ChapterPerson");+ });++ modelBuilder.Entity("ChapterTag", b =>+ {+ b.Property<int>("ChaptersId")+ .HasColumnType("INTEGER");++ b.Property<int>("TagsId")+ .HasColumnType("INTEGER");++ b.HasKey("ChaptersId", "TagsId");++ b.HasIndex("TagsId");++ b.ToTable("ChapterTag");+ });++ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>+ {+ b.Property<int>("CollectionTagsId")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesMetadatasId")+ .HasColumnType("INTEGER");++ b.HasKey("CollectionTagsId", "SeriesMetadatasId");++ b.HasIndex("SeriesMetadatasId");++ b.ToTable("CollectionTagSeriesMetadata");+ });++ modelBuilder.Entity("GenreSeriesMetadata", b =>+ {+ b.Property<int>("GenresId")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesMetadatasId")+ .HasColumnType("INTEGER");++ b.HasKey("GenresId", "SeriesMetadatasId");++ b.HasIndex("SeriesMetadatasId");++ b.ToTable("GenreSeriesMetadata");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("ClaimType")+ .HasColumnType("TEXT");++ b.Property<string>("ClaimValue")+ .HasColumnType("TEXT");++ b.Property<int>("RoleId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("RoleId");++ b.ToTable("AspNetRoleClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("ClaimType")+ .HasColumnType("TEXT");++ b.Property<string>("ClaimValue")+ .HasColumnType("TEXT");++ b.Property<int>("UserId")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("AspNetUserClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>+ {+ b.Property<string>("LoginProvider")+ .HasColumnType("TEXT");++ b.Property<string>("ProviderKey")+ .HasColumnType("TEXT");++ b.Property<string>("ProviderDisplayName")+ .HasColumnType("TEXT");++ b.Property<int>("UserId")+ .HasColumnType("INTEGER");++ b.HasKey("LoginProvider", "ProviderKey");++ b.HasIndex("UserId");++ b.ToTable("AspNetUserLogins", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>+ {+ b.Property<int>("UserId")+ .HasColumnType("INTEGER");++ b.Property<string>("LoginProvider")+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<string>("Value")+ .HasColumnType("TEXT");++ b.HasKey("UserId", "LoginProvider", "Name");++ b.ToTable("AspNetUserTokens", (string)null);+ });++ modelBuilder.Entity("PersonSeriesMetadata", b =>+ {+ b.Property<int>("PeopleId")+ .HasColumnType("INTEGER");++ b.Property<int>("SeriesMetadatasId")+ .HasColumnType("INTEGER");++ b.HasKey("PeopleId", "SeriesMetadatasId");++ b.HasIndex("SeriesMetadatasId");++ b.ToTable("PersonSeriesMetadata");+ });++ modelBuilder.Entity("SeriesMetadataTag", b =>+ {+ b.Property<int>("SeriesMetadatasId")+ .HasColumnType("INTEGER");++ b.Property<int>("TagsId")+ .HasColumnType("INTEGER");++ b.HasKey("SeriesMetadatasId", "TagsId");++ b.HasIndex("TagsId");++ b.ToTable("SeriesMetadataTag");+ });++ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>+ {+ b.HasOne("API.Entities.AppUser", "AppUser")+ .WithMany("Bookmarks")+ .HasForeignKey("AppUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("AppUser");+ });++ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>+ {+ b.HasOne("API.Entities.AppUser", "AppUser")+ .WithOne("UserPreferences")+ .HasForeignKey("API.Entities.AppUserPreferences", "AppUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.SiteTheme", "Theme")+ .WithMany()+ .HasForeignKey("ThemeId");++ b.Navigation("AppUser");++ b.Navigation("Theme");+ });++ modelBuilder.Entity("API.Entities.AppUserProgress", b =>+ {+ b.HasOne("API.Entities.AppUser", "AppUser")+ .WithMany("Progresses")+ .HasForeignKey("AppUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Series", null)+ .WithMany("Progress")+ .HasForeignKey("SeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("AppUser");+ });++ modelBuilder.Entity("API.Entities.AppUserRating", b =>+ {+ b.HasOne("API.Entities.AppUser", "AppUser")+ .WithMany("Ratings")+ .HasForeignKey("AppUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Series", null)+ .WithMany("Ratings")+ .HasForeignKey("SeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("AppUser");+ });++ modelBuilder.Entity("API.Entities.AppUserRole", b =>+ {+ b.HasOne("API.Entities.AppRole", "Role")+ .WithMany("UserRoles")+ .HasForeignKey("RoleId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.AppUser", "User")+ .WithMany("UserRoles")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Role");++ b.Navigation("User");+ });++ modelBuilder.Entity("API.Entities.Chapter", b =>+ {+ b.HasOne("API.Entities.Volume", "Volume")+ .WithMany("Chapters")+ .HasForeignKey("VolumeId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Volume");+ });++ modelBuilder.Entity("API.Entities.Device", b =>+ {+ b.HasOne("API.Entities.AppUser", "AppUser")+ .WithMany("Devices")+ .HasForeignKey("AppUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("AppUser");+ });++ modelBuilder.Entity("API.Entities.FolderPath", b =>+ {+ b.HasOne("API.Entities.Library", "Library")+ .WithMany("Folders")+ .HasForeignKey("LibraryId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Library");+ });++ modelBuilder.Entity("API.Entities.MangaFile", b =>+ {+ b.HasOne("API.Entities.Chapter", "Chapter")+ .WithMany("Files")+ .HasForeignKey("ChapterId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Chapter");+ });++ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>+ {+ b.HasOne("API.Entities.Series", "Series")+ .WithOne("Metadata")+ .HasForeignKey("API.Entities.Metadata.SeriesMetadata", "SeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Series");+ });++ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>+ {+ b.HasOne("API.Entities.Series", "Series")+ .WithMany("Relations")+ .HasForeignKey("SeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Series", "TargetSeries")+ .WithMany("RelationOf")+ .HasForeignKey("TargetSeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Series");++ b.Navigation("TargetSeries");+ });++ modelBuilder.Entity("API.Entities.ReadingList", b =>+ {+ b.HasOne("API.Entities.AppUser", "AppUser")+ .WithMany("ReadingLists")+ .HasForeignKey("AppUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("AppUser");+ });++ modelBuilder.Entity("API.Entities.ReadingListItem", b =>+ {+ b.HasOne("API.Entities.Chapter", "Chapter")+ .WithMany()+ .HasForeignKey("ChapterId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.ReadingList", "ReadingList")+ .WithMany("Items")+ .HasForeignKey("ReadingListId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Series", "Series")+ .WithMany()+ .HasForeignKey("SeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Volume", "Volume")+ .WithMany()+ .HasForeignKey("VolumeId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Chapter");++ b.Navigation("ReadingList");++ b.Navigation("Series");++ b.Navigation("Volume");+ });++ modelBuilder.Entity("API.Entities.Series", b =>+ {+ b.HasOne("API.Entities.AppUser", null)+ .WithMany("WantToRead")+ .HasForeignKey("AppUserId");++ b.HasOne("API.Entities.Library", "Library")+ .WithMany("Series")+ .HasForeignKey("LibraryId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Library");+ });++ modelBuilder.Entity("API.Entities.Volume", b =>+ {+ b.HasOne("API.Entities.Series", "Series")+ .WithMany("Volumes")+ .HasForeignKey("SeriesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Series");+ });++ modelBuilder.Entity("AppUserLibrary", b =>+ {+ b.HasOne("API.Entities.AppUser", null)+ .WithMany()+ .HasForeignKey("AppUsersId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Library", null)+ .WithMany()+ .HasForeignKey("LibrariesId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("ChapterGenre", b =>+ {+ b.HasOne("API.Entities.Chapter", null)+ .WithMany()+ .HasForeignKey("ChaptersId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Genre", null)+ .WithMany()+ .HasForeignKey("GenresId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("ChapterPerson", b =>+ {+ b.HasOne("API.Entities.Chapter", null)+ .WithMany()+ .HasForeignKey("ChapterMetadatasId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Person", null)+ .WithMany()+ .HasForeignKey("PeopleId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("ChapterTag", b =>+ {+ b.HasOne("API.Entities.Chapter", null)+ .WithMany()+ .HasForeignKey("ChaptersId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Tag", null)+ .WithMany()+ .HasForeignKey("TagsId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>+ {+ b.HasOne("API.Entities.CollectionTag", null)+ .WithMany()+ .HasForeignKey("CollectionTagsId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)+ .WithMany()+ .HasForeignKey("SeriesMetadatasId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("GenreSeriesMetadata", b =>+ {+ b.HasOne("API.Entities.Genre", null)+ .WithMany()+ .HasForeignKey("GenresId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)+ .WithMany()+ .HasForeignKey("SeriesMetadatasId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>+ {+ b.HasOne("API.Entities.AppRole", null)+ .WithMany()+ .HasForeignKey("RoleId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>+ {+ b.HasOne("API.Entities.AppUser", null)+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>+ {+ b.HasOne("API.Entities.AppUser", null)+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>+ {+ b.HasOne("API.Entities.AppUser", null)+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("PersonSeriesMetadata", b =>+ {+ b.HasOne("API.Entities.Person", null)+ .WithMany()+ .HasForeignKey("PeopleId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)+ .WithMany()+ .HasForeignKey("SeriesMetadatasId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("SeriesMetadataTag", b =>+ {+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)+ .WithMany()+ .HasForeignKey("SeriesMetadatasId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("API.Entities.Tag", null)+ .WithMany()+ .HasForeignKey("TagsId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();+ });++ modelBuilder.Entity("API.Entities.AppRole", b =>+ {+ b.Navigation("UserRoles");+ });++ modelBuilder.Entity("API.Entities.AppUser", b =>+ {+ b.Navigation("Bookmarks");++ b.Navigation("Devices");++ b.Navigation("Progresses");++ b.Navigation("Ratings");++ b.Navigation("ReadingLists");++ b.Navigation("UserPreferences");++ b.Navigation("UserRoles");++ b.Navigation("WantToRead");+ });++ modelBuilder.Entity("API.Entities.Chapter", b =>+ {+ b.Navigation("Files");+ });++ modelBuilder.Entity("API.Entities.Library", b =>+ {+ b.Navigation("Folders");++ b.Navigation("Series");+ });++ modelBuilder.Entity("API.Entities.ReadingList", b =>+ {+ b.Navigation("Items");+ });++ modelBuilder.Entity("API.Entities.Series", b =>+ {+ b.Navigation("Metadata");++ b.Navigation("Progress");++ b.Navigation("Ratings");++ b.Navigation("RelationOf");++ b.Navigation("Relations");++ b.Navigation("Volumes");+ });++ modelBuilder.Entity("API.Entities.Volume", b =>+ {+ b.Navigation("Chapters");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/API/Data/Migrations/20230203112022_RemoveExternalFromTagAndGenre.cs b/API/Data/Migrations/20230203112022_RemoveExternalFromTagAndGenre.csnew file mode 100644index 000000000..44216e4db--- /dev/null+++ b/API/Data/Migrations/20230203112022_RemoveExternalFromTagAndGenre.cs@@ -0,0 +1,77 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace API.Data.Migrations+{+ public partial class RemoveExternalFromTagAndGenre : Migration+ {+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "IX_Tag_NormalizedTitle_ExternalTag",+ table: "Tag");++ migrationBuilder.DropIndex(+ name: "IX_Genre_NormalizedTitle_ExternalTag",+ table: "Genre");++ migrationBuilder.DropColumn(+ name: "ExternalTag",+ table: "Tag");++ migrationBuilder.DropColumn(+ name: "ExternalTag",+ table: "Genre");++ migrationBuilder.CreateIndex(+ name: "IX_Tag_NormalizedTitle",+ table: "Tag",+ column: "NormalizedTitle",+ unique: true);++ migrationBuilder.CreateIndex(+ name: "IX_Genre_NormalizedTitle",+ table: "Genre",+ column: "NormalizedTitle",+ unique: true);+ }++ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "IX_Tag_NormalizedTitle",+ table: "Tag");++ migrationBuilder.DropIndex(+ name: "IX_Genre_NormalizedTitle",+ table: "Genre");++ migrationBuilder.AddColumn<bool>(+ name: "ExternalTag",+ table: "Tag",+ type: "INTEGER",+ nullable: false,+ defaultValue: false);++ migrationBuilder.AddColumn<bool>(+ name: "ExternalTag",+ table: "Genre",+ type: "INTEGER",+ nullable: false,+ defaultValue: false);++ migrationBuilder.CreateIndex(+ name: "IX_Tag_NormalizedTitle_ExternalTag",+ table: "Tag",+ columns: new[] { "NormalizedTitle", "ExternalTag" },+ unique: true);++ migrationBuilder.CreateIndex(+ name: "IX_Genre_NormalizedTitle_ExternalTag",+ table: "Genre",+ columns: new[] { "NormalizedTitle", "ExternalTag" },+ unique: true);+ }+ }+}diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.csindex d5bda4ef4..13a553b30 100644--- a/API/Data/Migrations/DataContextModelSnapshot.cs+++ b/API/Data/Migrations/DataContextModelSnapshot.cs@@ -528,9 +528,6 @@ namespace API.Data.Migrations.ValueGeneratedOnAdd().HasColumnType("INTEGER");- b.Property<bool>("ExternalTag")- .HasColumnType("INTEGER");-b.Property<string>("NormalizedTitle").HasColumnType("TEXT");@@ -539,7 +536,7 @@ namespace API.Data.Migrationsb.HasKey("Id");- b.HasIndex("NormalizedTitle", "ExternalTag")+ b.HasIndex("NormalizedTitle").IsUnique();b.ToTable("Genre");@@ -1036,9 +1033,6 @@ namespace API.Data.Migrations.ValueGeneratedOnAdd().HasColumnType("INTEGER");- b.Property<bool>("ExternalTag")- .HasColumnType("INTEGER");-b.Property<string>("NormalizedTitle").HasColumnType("TEXT");@@ -1047,7 +1041,7 @@ namespace API.Data.Migrationsb.HasKey("Id");- b.HasIndex("NormalizedTitle", "ExternalTag")+ b.HasIndex("NormalizedTitle").IsUnique();b.ToTable("Tag");diff --git a/API/Data/Repositories/GenreRepository.cs b/API/Data/Repositories/GenreRepository.csindex 464914b70..2533a40cf 100644--- a/API/Data/Repositories/GenreRepository.cs+++ b/API/Data/Repositories/GenreRepository.cs@@ -56,7 +56,7 @@ public class GenreRepository : IGenreRepositoryvar genresWithNoConnections = await _context.Genre.Include(p => p.SeriesMetadatas).Include(p => p.Chapters)- .Where(p => p.SeriesMetadatas.Count == 0 && p.Chapters.Count == 0 && p.ExternalTag == removeExternal)+ .Where(p => p.SeriesMetadatas.Count == 0 && p.Chapters.Count == 0).AsSplitQuery().ToListAsync();diff --git a/API/Data/Repositories/TagRepository.cs b/API/Data/Repositories/TagRepository.csindex ac88d04a7..07f895193 100644--- a/API/Data/Repositories/TagRepository.cs+++ b/API/Data/Repositories/TagRepository.cs@@ -46,7 +46,7 @@ public class TagRepository : ITagRepositoryvar tagsWithNoConnections = await _context.Tag.Include(p => p.SeriesMetadatas).Include(p => p.Chapters)- .Where(p => p.SeriesMetadatas.Count == 0 && p.Chapters.Count == 0 && p.ExternalTag == removeExternal)+ .Where(p => p.SeriesMetadatas.Count == 0 && p.Chapters.Count == 0).AsSplitQuery().ToListAsync();diff --git a/API/Entities/Genre.cs b/API/Entities/Genre.csindex ec9cdde0e..393a67860 100644--- a/API/Entities/Genre.cs+++ b/API/Entities/Genre.cs@@ -4,13 +4,12 @@ using Microsoft.EntityFrameworkCore;namespace API.Entities;-[Index(nameof(NormalizedTitle), nameof(ExternalTag), IsUnique = true)]+[Index(nameof(NormalizedTitle), IsUnique = true)]public class Genre{public int Id { get; set; }public string Title { get; set; }public string NormalizedTitle { get; set; }- public bool ExternalTag { get; set; }public ICollection<SeriesMetadata> SeriesMetadatas { get; set; }public ICollection<Chapter> Chapters { get; set; }diff --git a/API/Entities/Person.cs b/API/Entities/Person.csindex 4029b6af9..a7b8ea1c6 100644--- a/API/Entities/Person.cs+++ b/API/Entities/Person.cs@@ -4,18 +4,12 @@ using API.Entities.Metadata;namespace API.Entities;-public enum ProviderSource-{- Local = 1,- External = 2-}public class Person{public int Id { get; set; }public string Name { get; set; }public string NormalizedName { get; set; }public PersonRole Role { get; set; }- //public ProviderSource Source { get; set; }// Relationshipspublic ICollection<SeriesMetadata> SeriesMetadatas { get; set; }diff --git a/API/Entities/Tag.cs b/API/Entities/Tag.csindex 5d1631760..1676b2fd2 100644--- a/API/Entities/Tag.cs+++ b/API/Entities/Tag.cs@@ -4,13 +4,12 @@ using Microsoft.EntityFrameworkCore;namespace API.Entities;-[Index(nameof(NormalizedTitle), nameof(ExternalTag), IsUnique = true)]+[Index(nameof(NormalizedTitle), IsUnique = true)]public class Tag{public int Id { get; set; }public string Title { get; set; }public string NormalizedTitle { get; set; }- public bool ExternalTag { get; set; }public ICollection<SeriesMetadata> SeriesMetadatas { get; set; }public ICollection<Chapter> Chapters { get; set; }diff --git a/API/Helpers/GenreHelper.cs b/API/Helpers/GenreHelper.csindex 631baf85c..f6d6e85e9 100644--- a/API/Helpers/GenreHelper.cs+++ b/API/Helpers/GenreHelper.cs@@ -14,20 +14,18 @@ public static class GenreHelper/// </summary>/// <param name="allGenres"></param>/// <param name="names"></param>- /// <param name="isExternal"></param>/// <param name="action"></param>- public static void UpdateGenre(ICollection<Genre> allGenres, IEnumerable<string> names, bool isExternal, Action<Genre> action)+ public static void UpdateGenre(ICollection<Genre> allGenres, IEnumerable<string> names, Action<Genre> action){foreach (var name in names){if (string.IsNullOrEmpty(name.Trim())) continue;var normalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name);- var genre = allGenres.FirstOrDefault(p =>- p.NormalizedTitle.Equals(normalizedName) && p.ExternalTag == isExternal);+ var genre = allGenres.FirstOrDefault(p => p.NormalizedTitle.Equals(normalizedName));if (genre == null){- genre = DbFactory.Genre(name, false);+ genre = DbFactory.Genre(name);allGenres.Add(genre);}@@ -41,7 +39,7 @@ public static class GenreHelpervar existing = existingGenres.ToList();foreach (var genre in existing){- var existingPerson = removeAllExcept.FirstOrDefault(g => g.ExternalTag == genre.ExternalTag && genre.NormalizedTitle.Equals(g.NormalizedTitle));+ var existingPerson = removeAllExcept.FirstOrDefault(g => genre.NormalizedTitle.Equals(g.NormalizedTitle));if (existingPerson != null) continue;existingGenres.Remove(genre);action?.Invoke(genre);diff --git a/API/Helpers/TagHelper.cs b/API/Helpers/TagHelper.csindex f7b1abfd4..4844f9587 100644--- a/API/Helpers/TagHelper.cs+++ b/API/Helpers/TagHelper.cs@@ -14,9 +14,8 @@ public static class TagHelper/// </summary>/// <param name="allTags"></param>/// <param name="names"></param>- /// <param name="isExternal"></param>/// <param name="action">Callback for every item. Will give said item back and a bool if item was added</param>- public static void UpdateTag(ICollection<Tag> allTags, IEnumerable<string> names, bool isExternal, Action<Tag, bool> action)+ public static void UpdateTag(ICollection<Tag> allTags, IEnumerable<string> names, Action<Tag, bool> action){foreach (var name in names){@@ -26,11 +25,11 @@ public static class TagHelpervar normalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name);var genre = allTags.FirstOrDefault(p =>- p.NormalizedTitle.Equals(normalizedName) && p.ExternalTag == isExternal);+ p.NormalizedTitle.Equals(normalizedName));if (genre == null){added = true;- genre = DbFactory.Tag(name, false);+ genre = DbFactory.Tag(name);allTags.Add(genre);}@@ -43,7 +42,7 @@ public static class TagHelpervar existing = existingTags.ToList();foreach (var genre in existing){- var existingPerson = removeAllExcept.FirstOrDefault(g => g.ExternalTag == genre.ExternalTag && genre.NormalizedTitle.Equals(g.NormalizedTitle));+ var existingPerson = removeAllExcept.FirstOrDefault(g => genre.NormalizedTitle.Equals(g.NormalizedTitle));if (existingPerson != null) continue;existingTags.Remove(genre);action?.Invoke(genre);@@ -84,12 +83,12 @@ public static class TagHelper/// <param name="tags">Tags from metadata</param>/// <param name="isExternal">Remove external tags?</param>/// <param name="action">Callback which will be executed for each tag removed</param>- public static void RemoveTags(ICollection<Tag> existingTags, IEnumerable<string> tags, bool isExternal, Action<Tag> action = null)+ public static void RemoveTags(ICollection<Tag> existingTags, IEnumerable<string> tags, Action<Tag> action = null){var normalizedTags = tags.Select(Services.Tasks.Scanner.Parser.Parser.Normalize).ToList();foreach (var person in normalizedTags){- var existingTag = existingTags.FirstOrDefault(p => p.ExternalTag == isExternal && person.Equals(p.NormalizedTitle));+ var existingTag = existingTags.FirstOrDefault(p => person.Equals(p.NormalizedTitle));if (existingTag == null) continue;existingTags.Remove(existingTag);diff --git a/API/Services/SeriesService.cs b/API/Services/SeriesService.csindex b2e190e04..1dffcd1ac 100644--- a/API/Services/SeriesService.cs+++ b/API/Services/SeriesService.cs@@ -115,7 +115,7 @@ public class SeriesService : ISeriesService}series.Metadata.CollectionTags ??= new List<CollectionTag>();- UpdateRelatedList(updateSeriesMetadataDto.CollectionTags, series, allCollectionTags, (tag) =>+ UpdateCollectionsList(updateSeriesMetadataDto.CollectionTags, series, allCollectionTags, (tag) =>{series.Metadata.CollectionTags.Add(tag);});@@ -210,7 +210,7 @@ public class SeriesService : ISeriesService}- private static void UpdateRelatedList(ICollection<CollectionTagDto> tags, Series series, IReadOnlyCollection<CollectionTag> allTags,+ public static void UpdateCollectionsList(ICollection<CollectionTagDto> tags, Series series, IReadOnlyCollection<CollectionTag> allTags,Action<CollectionTag> handleAdd){// TODO: Move UpdateRelatedList to a helper so we can easily test@@ -278,7 +278,7 @@ public class SeriesService : ISeriesServiceelse{// Add new tag- handleAdd(DbFactory.Genre(tagTitle, false));+ handleAdd(DbFactory.Genre(tagTitle));isModified = true;}}@@ -320,7 +320,7 @@ public class SeriesService : ISeriesServiceelse{// Add new tag- handleAdd(DbFactory.Tag(tagTitle, false));+ handleAdd(DbFactory.Tag(tagTitle));isModified = true;}}diff --git a/API/Services/Tasks/Scanner/Parser/Parser.cs b/API/Services/Tasks/Scanner/Parser/Parser.csindex a81ebfa29..39952c1fa 100644--- a/API/Services/Tasks/Scanner/Parser/Parser.cs+++ b/API/Services/Tasks/Scanner/Parser/Parser.cs@@ -945,7 +945,7 @@ public static class Parserpublic static string Normalize(string name){- return NormalizeRegex.Replace(name, string.Empty).ToLower();+ return NormalizeRegex.Replace(name, string.Empty).Trim().ToLower();}/// <summary>diff --git a/API/Services/Tasks/Scanner/ProcessSeries.cs b/API/Services/Tasks/Scanner/ProcessSeries.csindex cfc1ed224..527cc89ec 100644--- a/API/Services/Tasks/Scanner/ProcessSeries.cs+++ b/API/Services/Tasks/Scanner/ProcessSeries.cs@@ -48,9 +48,9 @@ public class ProcessSeries : IProcessSeriesprivate readonly IWordCountAnalyzerService _wordCountAnalyzerService;private readonly ICollectionTagService _collectionTagService;- private IList<Genre> _genres;+ private Dictionary<string, Genre> _genres;private IList<Person> _people;- private IList<Tag> _tags;+ private Dictionary<string, Tag> _tags;private Dictionary<string, CollectionTag> _collectionTags;public ProcessSeries(IUnitOfWork unitOfWork, ILogger<ProcessSeries> logger, IEventHub eventHub,@@ -75,9 +75,9 @@ public class ProcessSeries : IProcessSeries/// </summary>public async Task Prime(){- _genres = await _unitOfWork.GenreRepository.GetAllGenresAsync();+ _genres = (await _unitOfWork.GenreRepository.GetAllGenresAsync()).ToDictionary(t => t.NormalizedTitle);_people = await _unitOfWork.PersonRepository.GetAllPeople();- _tags = await _unitOfWork.TagRepository.GetAllTagsAsync();+ _tags = (await _unitOfWork.TagRepository.GetAllTagsAsync()).ToDictionary(t => t.NormalizedTitle);_collectionTags = (await _unitOfWork.CollectionTagRepository.GetAllTagsAsync(CollectionTagIncludes.SeriesMetadata)).ToDictionary(t => t.NormalizedTitle);@@ -673,14 +673,14 @@ public class ProcessSeries : IProcessSeriesPersonHelper.AddPersonIfNotExists(chapter.People, person);}- void AddGenre(Genre genre)+ void AddGenre(Genre genre, bool newTag){- GenreHelper.AddGenreIfNotExists(chapter.Genres, genre);+ chapter.Genres.Add(genre);}void AddTag(Tag tag, bool added){- TagHelper.AddTagIfNotExists(chapter.Tags, tag);+ chapter.Tags.Add(tag);}@@ -745,14 +745,13 @@ public class ProcessSeries : IProcessSeriesAddPerson);var genres = GetTagValues(comicInfo.Genre);- GenreHelper.KeepOnlySameGenreBetweenLists(chapter.Genres, genres.Select(g => DbFactory.Genre(g, false)).ToList());- UpdateGenre(genres, false,- AddGenre);+ GenreHelper.KeepOnlySameGenreBetweenLists(chapter.Genres,+ genres.Select(DbFactory.Genre).ToList());+ UpdateGenre(genres, AddGenre);var tags = GetTagValues(comicInfo.Tags);- TagHelper.KeepOnlySameTagBetweenLists(chapter.Tags, tags.Select(t => DbFactory.Tag(t, false)).ToList());- UpdateTag(tags, false,- AddTag);+ TagHelper.KeepOnlySameTagBetweenLists(chapter.Tags, tags.Select(DbFactory.Tag).ToList());+ UpdateTag(tags, AddTag);}private static IList<string> GetTagValues(string comicInfoTagSeparatedByComma)@@ -760,7 +759,7 @@ public class ProcessSeries : IProcessSeriesif (!string.IsNullOrEmpty(comicInfoTagSeparatedByComma)){- return comicInfoTagSeparatedByComma.Split(",").Select(s => s.Trim()).ToList();+ return comicInfoTagSeparatedByComma.Split(",").Select(s => s.Trim()).DistinctBy(s => s.Normalize()).ToList();}return ImmutableList<string>.Empty;}@@ -801,27 +800,27 @@ public class ProcessSeries : IProcessSeries////// </summary>/// <param name="names"></param>- /// <param name="isExternal"></param>- /// <param name="action"></param>- private void UpdateGenre(IEnumerable<string> names, bool isExternal, Action<Genre> action)+ /// <param name="action">Executes for each tag</param>+ private void UpdateGenre(IEnumerable<string> names, Action<Genre, bool> action){foreach (var name in names){- if (string.IsNullOrEmpty(name.Trim())) continue;-var normalizedName = Parser.Parser.Normalize(name);- var genre = _genres.FirstOrDefault(p =>- p.NormalizedTitle.Equals(normalizedName) && p.ExternalTag == isExternal);- if (genre == null)+ if (string.IsNullOrEmpty(normalizedName)) continue;++ _genres.TryGetValue(normalizedName, out var genre);+ var newTag = genre == null;+ if (newTag){- genre = DbFactory.Genre(name, false);+ genre = DbFactory.Genre(name);lock (_genres){- _genres.Add(genre);+ _genres.Add(normalizedName, genre);+ _unitOfWork.GenreRepository.Attach(genre);}}- action(genre);+ action(genre, newTag);}}@@ -829,26 +828,23 @@ public class ProcessSeries : IProcessSeries////// </summary>/// <param name="names"></param>- /// <param name="isExternal"></param>/// <param name="action">Callback for every item. Will give said item back and a bool if item was added</param>- private void UpdateTag(IEnumerable<string> names, bool isExternal, Action<Tag, bool> action)+ private void UpdateTag(IEnumerable<string> names, Action<Tag, bool> action){foreach (var name in names){if (string.IsNullOrEmpty(name.Trim())) continue;- var added = false;var normalizedName = Parser.Parser.Normalize(name);+ _tags.TryGetValue(normalizedName, out var tag);- var tag = _tags.FirstOrDefault(p =>- p.NormalizedTitle.Equals(normalizedName) && p.ExternalTag == isExternal);+ var added = tag == null;if (tag == null){- added = true;- tag = DbFactory.Tag(name, false);+ tag = DbFactory.Tag(name);lock (_tags){- _tags.Add(tag);+ _tags.Add(normalizedName, tag);}}diff --git a/openapi.json b/openapi.jsonindex 4a306bfab..1eb30f82b 100644--- a/openapi.json+++ b/openapi.json@@ -7,7 +7,7 @@"name": "GPL-3.0","url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"},- "version": "0.6.1.33"+ "version": "0.6.1.34"},"servers": [{@@ -10935,9 +10935,6 @@"type": "string","nullable": true},- "externalTag": {- "type": "boolean"- },"seriesMetadatas": {"type": "array","items": {@@ -13562,9 +13559,6 @@"type": "string","nullable": true},- "externalTag": {- "type": "boolean"- },"seriesMetadatas": {"type": "array","items": {