Skip to content

Commit 292dc55

Browse files
authored
v0.8.5 - Metadata Downloading & PDF Metadata! (#3597)
1 parent 41cc3df commit 292dc55

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ body:
2828
label: Kavita Version Number - If you don not see your version number listed, please update Kavita and see if your issue still persists.
2929
multiple: false
3030
options:
31-
- 0.8.4.2 - Stable
31+
- 0.8.5 - Stable
3232
- Nightly Testing Branch
3333
validations:
3434
required: true
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.Globalization;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using API.Entities;
7+
using API.Entities.History;
8+
using API.Services;
9+
using CsvHelper;
10+
using CsvHelper.Configuration.Attributes;
11+
using Kavita.Common.EnvironmentInfo;
12+
using Microsoft.EntityFrameworkCore;
13+
using Microsoft.Extensions.Logging;
14+
15+
namespace API.Data.ManualMigrations;
16+
17+
18+
/// <summary>
19+
/// v0.8.5 - Progress is extracted and saved in a csv since PDF parser has massive changes
20+
/// </summary>
21+
public static class MigrateProgressExportForV085
22+
{
23+
public static async Task Migrate(DataContext dataContext, IDirectoryService directoryService, ILogger<Program> logger)
24+
{
25+
try
26+
{
27+
if (await dataContext.ManualMigrationHistory.AnyAsync(m => m.Name == "MigrateProgressExportForV085"))
28+
{
29+
return;
30+
}
31+
32+
logger.LogCritical(
33+
"Running MigrateProgressExportForV085 migration - Please be patient, this may take some time. This is not an error");
34+
35+
var data = await dataContext.AppUserProgresses
36+
.Join(dataContext.Series, progress => progress.SeriesId, series => series.Id, (progress, series) => new { progress, series })
37+
.Join(dataContext.Volume, ps => ps.progress.VolumeId, volume => volume.Id, (ps, volume) => new { ps.progress, ps.series, volume })
38+
.Join(dataContext.Chapter, psv => psv.progress.ChapterId, chapter => chapter.Id, (psv, chapter) => new { psv.progress, psv.series, psv.volume, chapter })
39+
.Join(dataContext.MangaFile, psvc => psvc.chapter.Id, mangaFile => mangaFile.ChapterId, (psvc, mangaFile) => new { psvc.progress, psvc.series, psvc.volume, psvc.chapter, mangaFile })
40+
.Join(dataContext.AppUser, psvcm => psvcm.progress.AppUserId, appUser => appUser.Id, (psvcm, appUser) => new
41+
{
42+
LibraryId = psvcm.series.LibraryId,
43+
LibraryName = psvcm.series.Library.Name,
44+
SeriesName = psvcm.series.Name,
45+
VolumeRange = psvcm.volume.MinNumber + "-" + psvcm.volume.MaxNumber,
46+
VolumeLookupName = psvcm.volume.Name,
47+
ChapterRange = psvcm.chapter.Range,
48+
MangaFileName = psvcm.mangaFile.FileName,
49+
MangaFilePath = psvcm.mangaFile.FilePath,
50+
AppUserName = appUser.UserName,
51+
AppUserId = appUser.Id,
52+
PagesRead = psvcm.progress.PagesRead,
53+
BookScrollId = psvcm.progress.BookScrollId,
54+
ProgressCreated = psvcm.progress.Created,
55+
ProgressLastModified = psvcm.progress.LastModified
56+
}).ToListAsync();
57+
58+
59+
// Write the mapped data to a CSV file
60+
await using var writer = new StreamWriter(Path.Join(directoryService.ConfigDirectory, "progress_export-v0.8.5.csv"));
61+
await using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture);
62+
await csv.WriteRecordsAsync(data);
63+
64+
logger.LogCritical(
65+
"Running MigrateProgressExportForV085 migration - Completed. This is not an error");
66+
}
67+
catch (Exception ex)
68+
{
69+
// On new installs, the db isn't setup yet, so this has nothing to do
70+
}
71+
72+
dataContext.ManualMigrationHistory.Add(new ManualMigrationHistory()
73+
{
74+
Name = "MigrateProgressExportForV085",
75+
ProductVersion = BuildInfo.Version.ToString(),
76+
RanAt = DateTime.UtcNow
77+
});
78+
await dataContext.SaveChangesAsync();
79+
}
80+
}

API/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ public void Configure(IApplicationBuilder app, IBackgroundJobClient backgroundJo
282282
await ManualMigrateInvalidBlacklistSeries.Migrate(dataContext, logger);
283283
await ManualMigrateScrobbleErrors.Migrate(dataContext, logger);
284284
await ManualMigrateNeedsManualMatch.Migrate(dataContext, logger);
285+
await MigrateProgressExportForV085.Migrate(dataContext, directoryService, logger);
285286

286287
// Update the version in the DB after all migrations are run
287288
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);

Kavita.Common/Kavita.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>net9.0</TargetFramework>
44
<Company>kavitareader.com</Company>
55
<Product>Kavita</Product>
6-
<AssemblyVersion>0.8.5.1</AssemblyVersion>
6+
<AssemblyVersion>0.8.5.0</AssemblyVersion>
77
<NeutralLanguage>en</NeutralLanguage>
88
<InvariantGlobalization>true</InvariantGlobalization>
99
<TieredPGO>true</TieredPGO>

0 commit comments

Comments
 (0)