-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Foundational Rework (Round 2) (#2767)
- Loading branch information
1 parent
304fd8b
commit fc87dba
Showing
29 changed files
with
249 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using API.Entities; | ||
using API.Helpers.Builders; | ||
using API.Services.Tasks.Scanner.Parser; | ||
using Kavita.Common.EnvironmentInfo; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace API.Data.ManualMigrations; | ||
|
||
/// <summary> | ||
/// v0.8.0 changed the range to that it doesn't have filename by default | ||
/// </summary> | ||
public static class MigrateChapterRange | ||
{ | ||
public static async Task Migrate(DataContext dataContext, IUnitOfWork unitOfWork, ILogger<Program> logger) | ||
{ | ||
if (await dataContext.ManualMigrationHistory.AnyAsync(m => m.Name == "MigrateChapterRange")) | ||
{ | ||
return; | ||
} | ||
|
||
logger.LogCritical( | ||
"Running MigrateChapterRange migration - Please be patient, this may take some time. This is not an error"); | ||
|
||
var chapters = await dataContext.Chapter.ToListAsync(); | ||
foreach (var chapter in chapters) | ||
{ | ||
if (Parser.MinNumberFromRange(chapter.Range) == 0.0f) | ||
{ | ||
chapter.Range = chapter.GetNumberTitle(); | ||
} | ||
} | ||
|
||
|
||
// Save changes after processing all series | ||
if (dataContext.ChangeTracker.HasChanges()) | ||
{ | ||
await dataContext.SaveChangesAsync(); | ||
} | ||
|
||
dataContext.ManualMigrationHistory.Add(new ManualMigrationHistory() | ||
{ | ||
Name = "MigrateChapterRange", | ||
ProductVersion = BuildInfo.Version.ToString(), | ||
RanAt = DateTime.UtcNow | ||
}); | ||
|
||
await dataContext.SaveChangesAsync(); | ||
logger.LogCritical( | ||
"Running MigrateChapterRange migration - Completed. This is not an error"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.