Few fixes from last PR (#2160)

* Added a migration for existing ratings

* Fixed duplicating web links and changed so it has the see more functionality.

* One more unit test
This commit is contained in:
Joe Milazzo 2023-07-25 14:15:25 -05:00 committed by GitHub
parent cae8f45ad1
commit ce04e7421b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 7 deletions

View File

@ -381,6 +381,49 @@ public class ReaderServiceTests
Assert.Equal("2", actualChapter.Range);
}
[Fact]
public async Task GetNextChapterIdAsync_ShouldGetNextVolume_OnlyFloats()
{
// V1 -> V2
await ResetDb();
var series = new SeriesBuilder("Test")
.WithVolume(new VolumeBuilder("1.0")
.WithChapter(new ChapterBuilder("1").Build())
.Build())
.WithVolume(new VolumeBuilder("2.1")
.WithChapter(new ChapterBuilder("21").Build())
.Build())
.WithVolume(new VolumeBuilder("2.2")
.WithChapter(new ChapterBuilder("31").Build())
.Build())
.WithVolume(new VolumeBuilder("3.1")
.WithChapter(new ChapterBuilder("31").Build())
.Build())
.Build();
series.Library = new LibraryBuilder("Test LIb", LibraryType.Manga).Build();
_context.Series.Add(series);
_context.AppUser.Add(new AppUser()
{
UserName = "majora2007"
});
await _context.SaveChangesAsync();
var nextChapter = await _readerService.GetNextChapterIdAsync(1, 2, 2, 1);
var actualChapter = await _unitOfWork.ChapterRepository.GetChapterAsync(nextChapter);
Assert.Equal("31", actualChapter.Range);
}
[Fact]
public async Task GetNextChapterIdAsync_ShouldRollIntoNextVolume()
{

View File

@ -0,0 +1,32 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace API.Data.ManualMigrations;
/// <summary>
/// Introduced in v0.7.5.6 and v0.7.6, Ratings > 0 need to have "HasRatingSet"
/// </summary>
/// <remarks>Added in v0.7.5.6</remarks>
// ReSharper disable once InconsistentNaming
public static class MigrateExistingRatings
{
public static async Task Migrate(DataContext context, ILogger<Program> logger)
{
logger.LogCritical("Running MigrateExistingRatings migration - Please be patient, this may take some time. This is not an error");
foreach (var r in context.AppUserRating.Where(r => r.Rating > 0f))
{
r.HasBeenRated = true;
context.Entry(r).State = EntityState.Modified;
}
if (context.ChangeTracker.HasChanges())
{
await context.SaveChangesAsync();
}
logger.LogCritical("Running MigrateExistingRatings migration - Completed. This is not an error");
}
}

View File

@ -247,6 +247,9 @@ public class Startup
// v0.7.4
await MigrateDisableScrobblingOnComicLibraries.Migrate(unitOfWork, dataContext, logger);
// v0.7.6
await MigrateExistingRatings.Migrate(dataContext, logger);
// Update the version in the DB after all migrations are run
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);
installVersion.Value = BuildInfo.Version.ToString();

View File

@ -13,10 +13,10 @@
<ng-container *ngIf="WebLinks as links">
<app-metadata-detail [tags]="links" [libraryId]="series.libraryId" heading="Links">
<ng-template #itemTemplate let-item>
<a class="col me-1" [href]="link | safeHtml" target="_blank" rel="noopener noreferrer" *ngFor="let link of links" [title]="link">
<a class="col me-1" [href]="item | safeHtml" target="_blank" rel="noopener noreferrer" [title]="item">
<img width="24" height="24" class="lazyload img-placeholder"
[src]="imageService.errorWebLinkImage"
[attr.data-src]="imageService.getWebLinkImage(link)"
[attr.data-src]="imageService.getWebLinkImage(item)"
(error)="imageService.updateErroredWebLinkImage($event)"
aria-hidden="true" alt="">
</a>
@ -45,10 +45,10 @@
<app-metadata-detail [tags]="readingLists" [libraryId]="series.libraryId" heading="Reading Lists">
<ng-template #itemTemplate let-item>
<app-tag-badge a11y-click="13,32" class="col-auto" (click)="navigate('lists', item.id)" [selectionMode]="TagBadgeCursor.Clickable">
<span *ngIf="item.promoted">
<i class="fa fa-angle-double-up" aria-hidden="true"></i>&nbsp;
<span class="visually-hidden">(promoted)</span>
</span>
<span *ngIf="item.promoted">
<i class="fa fa-angle-double-up" aria-hidden="true"></i>&nbsp;
<span class="visually-hidden">(promoted)</span>
</span>
{{item.title}}
</app-tag-badge>
</ng-template>

View File

@ -7,7 +7,7 @@
"name": "GPL-3.0",
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
},
"version": "0.7.5.5"
"version": "0.7.5.7"
},
"servers": [
{