v0.8.5 - Metadata Downloading & PDF Metadata! (#3597)

This commit is contained in:
Joe Milazzo 2025-03-07 13:20:07 -06:00 committed by GitHub
parent 41cc3df654
commit 292dc55809
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 83 additions and 2 deletions

View File

@ -28,7 +28,7 @@ body:
label: Kavita Version Number - If you don not see your version number listed, please update Kavita and see if your issue still persists.
multiple: false
options:
- 0.8.4.2 - Stable
- 0.8.5 - Stable
- Nightly Testing Branch
validations:
required: true

View File

@ -0,0 +1,80 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using API.Entities;
using API.Entities.History;
using API.Services;
using CsvHelper;
using CsvHelper.Configuration.Attributes;
using Kavita.Common.EnvironmentInfo;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace API.Data.ManualMigrations;
/// <summary>
/// v0.8.5 - Progress is extracted and saved in a csv since PDF parser has massive changes
/// </summary>
public static class MigrateProgressExportForV085
{
public static async Task Migrate(DataContext dataContext, IDirectoryService directoryService, ILogger<Program> logger)
{
try
{
if (await dataContext.ManualMigrationHistory.AnyAsync(m => m.Name == "MigrateProgressExportForV085"))
{
return;
}
logger.LogCritical(
"Running MigrateProgressExportForV085 migration - Please be patient, this may take some time. This is not an error");
var data = await dataContext.AppUserProgresses
.Join(dataContext.Series, progress => progress.SeriesId, series => series.Id, (progress, series) => new { progress, series })
.Join(dataContext.Volume, ps => ps.progress.VolumeId, volume => volume.Id, (ps, volume) => new { ps.progress, ps.series, volume })
.Join(dataContext.Chapter, psv => psv.progress.ChapterId, chapter => chapter.Id, (psv, chapter) => new { psv.progress, psv.series, psv.volume, chapter })
.Join(dataContext.MangaFile, psvc => psvc.chapter.Id, mangaFile => mangaFile.ChapterId, (psvc, mangaFile) => new { psvc.progress, psvc.series, psvc.volume, psvc.chapter, mangaFile })
.Join(dataContext.AppUser, psvcm => psvcm.progress.AppUserId, appUser => appUser.Id, (psvcm, appUser) => new
{
LibraryId = psvcm.series.LibraryId,
LibraryName = psvcm.series.Library.Name,
SeriesName = psvcm.series.Name,
VolumeRange = psvcm.volume.MinNumber + "-" + psvcm.volume.MaxNumber,
VolumeLookupName = psvcm.volume.Name,
ChapterRange = psvcm.chapter.Range,
MangaFileName = psvcm.mangaFile.FileName,
MangaFilePath = psvcm.mangaFile.FilePath,
AppUserName = appUser.UserName,
AppUserId = appUser.Id,
PagesRead = psvcm.progress.PagesRead,
BookScrollId = psvcm.progress.BookScrollId,
ProgressCreated = psvcm.progress.Created,
ProgressLastModified = psvcm.progress.LastModified
}).ToListAsync();
// Write the mapped data to a CSV file
await using var writer = new StreamWriter(Path.Join(directoryService.ConfigDirectory, "progress_export-v0.8.5.csv"));
await using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture);
await csv.WriteRecordsAsync(data);
logger.LogCritical(
"Running MigrateProgressExportForV085 migration - Completed. This is not an error");
}
catch (Exception ex)
{
// On new installs, the db isn't setup yet, so this has nothing to do
}
dataContext.ManualMigrationHistory.Add(new ManualMigrationHistory()
{
Name = "MigrateProgressExportForV085",
ProductVersion = BuildInfo.Version.ToString(),
RanAt = DateTime.UtcNow
});
await dataContext.SaveChangesAsync();
}
}

View File

@ -282,6 +282,7 @@ public class Startup
await ManualMigrateInvalidBlacklistSeries.Migrate(dataContext, logger);
await ManualMigrateScrobbleErrors.Migrate(dataContext, logger);
await ManualMigrateNeedsManualMatch.Migrate(dataContext, logger);
await MigrateProgressExportForV085.Migrate(dataContext, directoryService, logger);
// Update the version in the DB after all migrations are run
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);

View File

@ -3,7 +3,7 @@
<TargetFramework>net9.0</TargetFramework>
<Company>kavitareader.com</Company>
<Product>Kavita</Product>
<AssemblyVersion>0.8.5.1</AssemblyVersion>
<AssemblyVersion>0.8.5.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<InvariantGlobalization>true</InvariantGlobalization>
<TieredPGO>true</TieredPGO>