mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-03 21:54:47 -04:00
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:
parent
cae8f45ad1
commit
ce04e7421b
@ -381,6 +381,49 @@ public class ReaderServiceTests
|
|||||||
Assert.Equal("2", actualChapter.Range);
|
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]
|
[Fact]
|
||||||
public async Task GetNextChapterIdAsync_ShouldRollIntoNextVolume()
|
public async Task GetNextChapterIdAsync_ShouldRollIntoNextVolume()
|
||||||
{
|
{
|
||||||
|
32
API/Data/ManualMigrations/MigrateExistingRatings.cs
Normal file
32
API/Data/ManualMigrations/MigrateExistingRatings.cs
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
@ -247,6 +247,9 @@ public class Startup
|
|||||||
// v0.7.4
|
// v0.7.4
|
||||||
await MigrateDisableScrobblingOnComicLibraries.Migrate(unitOfWork, dataContext, logger);
|
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
|
// Update the version in the DB after all migrations are run
|
||||||
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);
|
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);
|
||||||
installVersion.Value = BuildInfo.Version.ToString();
|
installVersion.Value = BuildInfo.Version.ToString();
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
<ng-container *ngIf="WebLinks as links">
|
<ng-container *ngIf="WebLinks as links">
|
||||||
<app-metadata-detail [tags]="links" [libraryId]="series.libraryId" heading="Links">
|
<app-metadata-detail [tags]="links" [libraryId]="series.libraryId" heading="Links">
|
||||||
<ng-template #itemTemplate let-item>
|
<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"
|
<img width="24" height="24" class="lazyload img-placeholder"
|
||||||
[src]="imageService.errorWebLinkImage"
|
[src]="imageService.errorWebLinkImage"
|
||||||
[attr.data-src]="imageService.getWebLinkImage(link)"
|
[attr.data-src]="imageService.getWebLinkImage(item)"
|
||||||
(error)="imageService.updateErroredWebLinkImage($event)"
|
(error)="imageService.updateErroredWebLinkImage($event)"
|
||||||
aria-hidden="true" alt="">
|
aria-hidden="true" alt="">
|
||||||
</a>
|
</a>
|
||||||
@ -45,10 +45,10 @@
|
|||||||
<app-metadata-detail [tags]="readingLists" [libraryId]="series.libraryId" heading="Reading Lists">
|
<app-metadata-detail [tags]="readingLists" [libraryId]="series.libraryId" heading="Reading Lists">
|
||||||
<ng-template #itemTemplate let-item>
|
<ng-template #itemTemplate let-item>
|
||||||
<app-tag-badge a11y-click="13,32" class="col-auto" (click)="navigate('lists', item.id)" [selectionMode]="TagBadgeCursor.Clickable">
|
<app-tag-badge a11y-click="13,32" class="col-auto" (click)="navigate('lists', item.id)" [selectionMode]="TagBadgeCursor.Clickable">
|
||||||
<span *ngIf="item.promoted">
|
<span *ngIf="item.promoted">
|
||||||
<i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
<i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
||||||
<span class="visually-hidden">(promoted)</span>
|
<span class="visually-hidden">(promoted)</span>
|
||||||
</span>
|
</span>
|
||||||
{{item.title}}
|
{{item.title}}
|
||||||
</app-tag-badge>
|
</app-tag-badge>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"name": "GPL-3.0",
|
"name": "GPL-3.0",
|
||||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||||
},
|
},
|
||||||
"version": "0.7.5.5"
|
"version": "0.7.5.7"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user