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
Release Testing Day 2 (#1937)
Joe Milazzoc70154f42851
diff --git a/API.Tests/Services/ReadingListServiceTests.cs b/API.Tests/Services/ReadingListServiceTests.csindex 050882052..dbfe1129d 100644--- a/API.Tests/Services/ReadingListServiceTests.cs+++ b/API.Tests/Services/ReadingListServiceTests.cs@@ -1203,10 +1203,67 @@ public class ReadingListServiceTests#region CreateReadingListsFromSeries+ private async Task<Tuple<Series, Series>> SetupData()+ {+ // Setup 2 series, only do this once tho+ if (await _unitOfWork.SeriesRepository.DoesSeriesNameExistInLibrary("Series 1", 1, MangaFormat.Archive))+ {+ return new Tuple<Series, Series>(await _unitOfWork.SeriesRepository.GetFullSeriesForSeriesIdAsync(1),+ await _unitOfWork.SeriesRepository.GetFullSeriesForSeriesIdAsync(2));+ }++ var library =+ await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(1,+ LibraryIncludes.Series | LibraryIncludes.AppUser);+ var user = new AppUserBuilder("majora2007", "[email protected]").Build();+ library!.AppUsers.Add(user);+ library.ManageReadingLists = true;++ // Setup the series for CreateReadingListsFromSeries+ var series1 = new SeriesBuilder("Series 1")+ .WithFormat(MangaFormat.Archive)+ .WithVolume(new VolumeBuilder("1")+ .WithChapter(new ChapterBuilder("1")+ .WithStoryArc("CreateReadingListsFromSeries")+ .WithStoryArcNumber("1")+ .Build())+ .WithChapter(new ChapterBuilder("2").Build())+ .Build())+ .Build();++ var series2 = new SeriesBuilder("Series 2")+ .WithFormat(MangaFormat.Archive)+ .WithVolume(new VolumeBuilder(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)+ .WithChapter(new ChapterBuilder("1").Build())+ .WithChapter(new ChapterBuilder("2").Build())+ .Build())+ .Build();++ library!.Series.Add(series1);+ library!.Series.Add(series2);++ await _unitOfWork.CommitAsync();++ return new Tuple<Series, Series>(series1, series2);+ }+// [Fact]// public async Task CreateReadingListsFromSeries_ShouldCreateFromSinglePair()// {+ // //await SetupData();+ //+ // var series1 = new SeriesBuilder("Series 1")+ // .WithFormat(MangaFormat.Archive)+ // .WithVolume(new VolumeBuilder("1")+ // .WithChapter(new ChapterBuilder("1")+ // .WithStoryArc("CreateReadingListsFromSeries")+ // .WithStoryArcNumber("1")+ // .Build())+ // .WithChapter(new ChapterBuilder("2").Build())+ // .Build())+ // .Build();//+ // _readingListService.CreateReadingListsFromSeries(series.Item1)// }#endregiondiff --git a/API/Data/Repositories/UserRepository.cs b/API/Data/Repositories/UserRepository.csindex 0f6b5dc99..8e58805d8 100644--- a/API/Data/Repositories/UserRepository.cs+++ b/API/Data/Repositories/UserRepository.cs@@ -228,7 +228,7 @@ public class UserRepository : IUserRepositorypublic async Task<AppUser> GetDefaultAdminUser(){return (await _userManager.GetUsersInRoleAsync(PolicyConstants.AdminRole))- .OrderByDescending(u => u.Created)+ .OrderBy(u => u.Created).First();}diff --git a/API/Entities/Metadata/SeriesMetadata.cs b/API/Entities/Metadata/SeriesMetadata.csindex 90eadba5d..188ed9692 100644--- a/API/Entities/Metadata/SeriesMetadata.cs+++ b/API/Entities/Metadata/SeriesMetadata.cs@@ -13,7 +13,7 @@ public class SeriesMetadata : IHasConcurrencyTokenpublic string Summary { get; set; } = string.Empty;- public ICollection<CollectionTag> CollectionTags { get; set; } = null!;+ public ICollection<CollectionTag> CollectionTags { get; set; } = new List<CollectionTag>();public ICollection<Genre> Genres { get; set; } = new List<Genre>();public ICollection<Tag> Tags { get; set; } = new List<Tag>();diff --git a/API/Helpers/Builders/ChapterBuilder.cs b/API/Helpers/Builders/ChapterBuilder.csindex 69e0f5eef..35b115998 100644--- a/API/Helpers/Builders/ChapterBuilder.cs+++ b/API/Helpers/Builders/ChapterBuilder.cs@@ -17,7 +17,7 @@ public class ChapterBuilder : IEntityBuilder<Chapter>{Range = string.IsNullOrEmpty(range) ? number : range,Title = string.IsNullOrEmpty(range) ? number : range,- Number = Services.Tasks.Scanner.Parser.Parser.MinNumberFromRange(number) + string.Empty,+ Number = Parser.MinNumberFromRange(number) + string.Empty,Files = new List<MangaFile>(),Pages = 1};@@ -42,12 +42,24 @@ public class ChapterBuilder : IEntityBuilder<Chapter>return this;}- private ChapterBuilder WithNumber(string number)+ public ChapterBuilder WithNumber(string number){_chapter.Number = number;return this;}+ public ChapterBuilder WithStoryArc(string arc)+ {+ _chapter.StoryArc = arc;+ return this;+ }++ public ChapterBuilder WithStoryArcNumber(string number)+ {+ _chapter.StoryArcNumber = number;+ return this;+ }+private ChapterBuilder WithRange(string range){_chapter.Range = range;diff --git a/API/Helpers/PersonHelper.cs b/API/Helpers/PersonHelper.csindex 1689340a3..ff73c6a74 100644--- a/API/Helpers/PersonHelper.cs+++ b/API/Helpers/PersonHelper.cs@@ -103,6 +103,7 @@ public static class PersonHelperif (string.IsNullOrEmpty(person.Name)) return;var existingPerson = metadataPeople.FirstOrDefault(p =>p.NormalizedName == person.Name.ToNormalized() && p.Role == person.Role);+if (existingPerson == null){metadataPeople.Add(person);diff --git a/API/Services/ReadingListService.cs b/API/Services/ReadingListService.csindex c3d1bb57a..8c99da39f 100644--- a/API/Services/ReadingListService.cs+++ b/API/Services/ReadingListService.cs@@ -13,9 +13,11 @@ using API.Entities;using API.Entities.Enums;using API.Helpers;using API.Helpers.Builders;+using API.Services.Tasks.Scanner.Parser;using API.SignalR;using Kavita.Common;using Microsoft.Extensions.Logging;+using Microsoft.IdentityModel.Tokens;namespace API.Services;@@ -447,7 +449,7 @@ public class ReadingListService : IReadingListServiceseries.Metadata ??= new SeriesMetadataBuilder().Build();foreach (var chapter in series.Volumes.SelectMany(v => v.Chapters)){- List<Tuple<string, string>> pairs = new List<Tuple<string, string>>();+ var pairs = new List<Tuple<string, string>>();if (!string.IsNullOrEmpty(chapter.StoryArc)){pairs.AddRange(GeneratePairs(chapter.Files.FirstOrDefault()!.FilePath, chapter.StoryArc, chapter.StoryArcNumber));@@ -459,7 +461,6 @@ public class ReadingListService : IReadingListServiceforeach (var arcPair in pairs){- var order = int.Parse(arcPair.Item2);var readingList = await _unitOfWork.ReadingListRepository.GetReadingListByTitleAsync(arcPair.Item1, user.Id);if (readingList == null){@@ -471,19 +472,36 @@ public class ReadingListService : IReadingListService}var items = readingList.Items.ToList();- var readingListItem = items.FirstOrDefault(item => item.Order == order);+ var order = int.Parse(arcPair.Item2);+ var readingListItem = items.FirstOrDefault(item => item.Order == order || item.ChapterId == chapter.Id);if (readingListItem == null){+ // If no number was provided in the reading list, we default to MaxValue and hence we should insert the item at the end of the list+ if (order == int.MaxValue)+ {+ order = items.Count > 0 ? items.Max(item => item.Order) + 1 : 0;+ }items.Add(new ReadingListItemBuilder(order, series.Id, chapter.VolumeId, chapter.Id).Build());}else{- ReorderItems(items, readingListItem.Id, order);+ if (order == int.MaxValue)+ {+ _logger.LogWarning("{Filename} has a missing StoryArcNumber/AlternativeNumber but list already exists with this item. Skipping item", chapter.Files.FirstOrDefault()?.FilePath);+ }+ else+ {+ ReorderItems(items, readingListItem.Id, order);+ }}readingList.Items = items;await CalculateReadingListAgeRating(readingList);- await _unitOfWork.CommitAsync();+ await CalculateStartAndEndDates(readingList);+ if (_unitOfWork.HasChanges())+ {+ await _unitOfWork.CommitAsync();+ }}}}@@ -495,14 +513,19 @@ public class ReadingListService : IReadingListServicevar arcs = storyArc.Split(",");var arcNumbers = storyArcNumbers.Split(",");- if (arcNumbers.Length != arcs.Length)+ if (arcNumbers.Count(s => !string.IsNullOrEmpty(s)) != arcs.Length){- _logger.LogError("There is a mismatch on StoryArc and StoryArcNumber for {FileName}", filename);+ _logger.LogWarning("There is a mismatch on StoryArc and StoryArcNumber for {FileName}. Def", filename);}var maxPairs = Math.Min(arcs.Length, arcNumbers.Length);for (var i = 0; i < maxPairs; i++){+ // When there is a mismatch on arcs and arc numbers, then we should default to a high number+ if (string.IsNullOrEmpty(arcNumbers[i]) && !string.IsNullOrEmpty(arcs[i]))+ {+ arcNumbers[i] = int.MaxValue.ToString();+ }if (string.IsNullOrEmpty(arcs[i]) || !int.TryParse(arcNumbers[i], out _)) continue;data.Add(new Tuple<string, string>(arcs[i], arcNumbers[i]));}diff --git a/API/Services/Tasks/Scanner/ProcessSeries.cs b/API/Services/Tasks/Scanner/ProcessSeries.csindex 785bc2960..d70dea58f 100644--- a/API/Services/Tasks/Scanner/ProcessSeries.cs+++ b/API/Services/Tasks/Scanner/ProcessSeries.cs@@ -196,8 +196,9 @@ public class ProcessSeries : IProcessSeries{await _unitOfWork.RollbackAsync();_logger.LogCritical(ex,- "[ScannerService] There was an issue writing to the database for series {@SeriesName}",+ "[ScannerService] There was an issue writing to the database for series {SeriesName}",series.Name);+ _logger.LogTrace("[ScannerService] Full Series Dump: {@Series}", series);await _eventHub.SendMessageAsync(MessageFactory.Error,MessageFactory.ErrorEvent($"There was an issue writing to the DB for Series {series}",@@ -222,7 +223,7 @@ public class ProcessSeries : IProcessSeries_logger.LogError(ex, "[ScannerService] There was an exception updating series for {SeriesName}", series.Name);}- await _metadataService.GenerateCoversForSeries(series, false);+ await _metadataService.GenerateCoversForSeries(series, (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).ConvertCoverToWebP);EnqueuePostSeriesProcessTasks(series.LibraryId, series.Id);}@@ -726,7 +727,18 @@ public class ProcessSeries : IProcessSeriesvoid AddPerson(Person person){- PersonHelper.AddPersonIfNotExists(chapter.People, person);+ // TODO: Temp have code inlined to help debug foreign key constraint issue+ //PersonHelper.AddPersonIfNotExists(chapter.People, person);+ if (string.IsNullOrEmpty(person.Name)) return;+ var existingPerson = chapter.People.FirstOrDefault(p =>+ p.NormalizedName == person.Name.ToNormalized() && p.Role == person.Role);+ _logger.LogTrace("[PersonHelper] Attempting to add {@Person} to {FileName} with ChapterID {ChapterId}, adding if not null: {@ExistingPerson}",+ person, chapter.Files.FirstOrDefault()?.FilePath, chapter.Id, existingPerson);++ if (existingPerson == null)+ {+ chapter.People.Add(person);+ }}void AddGenre(Genre genre, bool newTag)@@ -823,15 +835,19 @@ public class ProcessSeries : IProcessSerieslock (_peopleLock){var allPeopleTypeRole = _people.Where(p => p.Role == role).ToList();+ _logger.LogTrace("[UpdatePeople] for {Role} and Names of {Names}", role, names);+ _logger.LogTrace("[UpdatePeople] for {Role} found {@People}", role, allPeopleTypeRole.Select(p => new {p.Id, p.Name, SeriesMetadataIds = p.SeriesMetadatas?.Select(m => m.Id).ToList()}));foreach (var name in names){var normalizedName = name.ToNormalized();var person = allPeopleTypeRole.FirstOrDefault(p =>p.NormalizedName != null && p.NormalizedName.Equals(normalizedName));+if (person == null){person = new PersonBuilder(name, role).Build();+ _logger.LogTrace("[UpdatePeople] for {Role} no one found, adding to _people", role);_people.Add(person);}diff --git a/API/Services/Tasks/ScannerService.cs b/API/Services/Tasks/ScannerService.csindex f9eca3991..492107829 100644--- a/API/Services/Tasks/ScannerService.cs+++ b/API/Services/Tasks/ScannerService.cs@@ -531,7 +531,7 @@ public class ScannerService : IScannerService_logger.LogInformation("[ScannerService] Finished file scan in {ScanAndUpdateTime} milliseconds. Updating database", scanElapsedTime);- var time = DateTime.UtcNow;+ var time = DateTime.Now;foreach (var folderPath in library.Folders){folderPath.UpdateLastScanned(time);diff --git a/UI/Web/src/app/pipe/time-ago.pipe.ts b/UI/Web/src/app/pipe/time-ago.pipe.tsindex 2bbb5abe6..d44a483e8 100644--- a/UI/Web/src/app/pipe/time-ago.pipe.ts+++ b/UI/Web/src/app/pipe/time-ago.pipe.ts@@ -33,11 +33,12 @@ and modified})export class TimeAgoPipe implements PipeTransform, OnDestroy {- private timer: number | null = null;+ private timer: number | null = null;constructor(private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) {}transform(value: string) {this.removeTimer();const d = new Date(value);+ console.log('date: ', d);const now = new Date();const seconds = Math.round(Math.abs((now.getTime() - d.getTime()) / 1000));const timeToUpdate = (Number.isNaN(seconds)) ? 1000 : this.getSecondsUntilUpdate(seconds) * 1000;@@ -61,37 +62,37 @@ export class TimeAgoPipe implements PipeTransform, OnDestroy {return '';}- if (seconds <= 45) {- return 'just now';- }- if (seconds <= 90) {- return 'a minute ago';- }- if (minutes <= 45) {- return minutes + ' minutes ago';- }- if (minutes <= 90) {- return 'an hour ago';- }- if (hours <= 22) {- return hours + ' hours ago';- }- if (hours <= 36) {- return 'a day ago';- }- if (days <= 25) {- return days + ' days ago';- }- if (days <= 45) {- return 'a month ago';- }- if (days <= 345) {- return months + ' months ago';- }- if (days <= 545) {- return 'a year ago';- }- return years + ' years ago';+ if (seconds <= 45) {+ return 'just now';+ }+ if (seconds <= 90) {+ return 'a minute ago';+ }+ if (minutes <= 45) {+ return minutes + ' minutes ago';+ }+ if (minutes <= 90) {+ return 'an hour ago';+ }+ if (hours <= 22) {+ return hours + ' hours ago';+ }+ if (hours <= 36) {+ return 'a day ago';+ }+ if (days <= 25) {+ return days + ' days ago';+ }+ if (days <= 45) {+ return 'a month ago';+ }+ if (days <= 345) {+ return months + ' months ago';+ }+ if (days <= 545) {+ return 'a year ago';+ }+ return years + ' years ago';}ngOnDestroy(): void {diff --git a/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.html b/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.htmlindex abfa81ef3..d77d722a8 100644--- a/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.html+++ b/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.html@@ -58,7 +58,7 @@aria-describedby="starting-year-header"><div id="inviteForm-validations" class="invalid-feedback" *ngIf="reviewGroup.dirty || reviewGroup.touched"><div *ngIf="formControl.errors?.min || formControl.errors?.max">- Must be between 1 and 12 or blank+ Must be greater than 1000, 0 or blank</div></div></div>@@ -84,7 +84,7 @@aria-describedby="ending-year-header"><div id="inviteForm-validations" class="invalid-feedback" *ngIf="reviewGroup.dirty || reviewGroup.touched"><div *ngIf="formControl.errors?.min || formControl.errors?.max">- Must be between 1 and 12 or blank+ Must be greater than 1000, 0 or blank</div></div></div>@@ -109,7 +109,7 @@</div><div class="modal-footer"><button type="button" class="btn btn-secondary" (click)="close()">Close</button>- <button type="submit" class="btn btn-primary" [disabled]="!reviewGroup.valid" (click)="save()">Save</button>+ <button type="submit" class="btn btn-primary" (click)="save()">Save</button></div>diff --git a/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.ts b/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.tsindex 0c871bd17..ee625c2ed 100644--- a/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.ts+++ b/UI/Web/src/app/reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component.ts@@ -116,6 +116,8 @@ export class EditReadingListModalComponent implements OnInit, OnDestroy {updateSelectedIndex(index: number) {this.coverImageIndex = index;+ console.log(this.coverImageIndex)+ this.cdRef.detectChanges();}updateSelectedImage(url: string) {diff --git a/UI/Web/src/app/registration/user-login/user-login.component.html b/UI/Web/src/app/registration/user-login/user-login.component.htmlindex ffbd27bae..f8d2f85f5 100644--- a/UI/Web/src/app/registration/user-login/user-login.component.html+++ b/UI/Web/src/app/registration/user-login/user-login.component.html@@ -12,7 +12,7 @@<div class="mb-2"><label for="password" class="form-label visually-hidden">Password</label><input class="form-control custom-input" formControlName="password" name="password"- id="password" type="password" ngModel pattern="^.{6,32}$" placeholder="Password">+ id="password" type="password" pattern="^.{6,32}$" placeholder="Password"><div id="inviteForm-validations" class="invalid-feedback" *ngIf="loginForm.get('password')?.errors?.pattern" ><div class="" *ngIf="loginForm.get('password')?.errors?.pattern">Password must be between 6 and 32 characters in length