From 0aa2cebc1bfc8ab089be0c21f9b5f4cd780ae687 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Sat, 24 Feb 2024 23:45:38 +0200 Subject: [PATCH] Fix --- src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs b/src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs index 6d07b62..a53ff3c 100644 --- a/src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs +++ b/src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs @@ -36,7 +36,8 @@ protected override async Task ExecuteAsync(CancellationToken ct) const int take = 10000; var idDataCount = sqlite.Set().AsNoTracking().Count(); - for (var i = 0; i < idDataCount % take; i+= take) + var idDataIterations = idDataCount % take; + for (var i = 0; i < idDataIterations; i++) { var data = await sqlite.Set().AsNoTracking().OrderBy(x => x.FileId).Skip(i * take).Take(take).AsAsyncEnumerable() .Select(x => x with @@ -48,7 +49,8 @@ protected override async Task ExecuteAsync(CancellationToken ct) } var fileDataCount = sqlite.Set().AsNoTracking().Count(); - for (var i = 0; i < fileDataCount % take; i+= take) + var fileDataIterations = fileDataCount % take; + for (var i = 0; i < fileDataIterations; i+= take) { var data = await sqlite.Set().AsNoTracking().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).ToArrayAsync(ct); await postgres.Set().AddRangeAsync(data, ct); @@ -56,7 +58,8 @@ protected override async Task ExecuteAsync(CancellationToken ct) } var jsonDataCount = sqlite.Set().AsNoTracking().Count(); - for (var i = 0; i < jsonDataCount % take; i+= take) + var jsonDataIterations = jsonDataCount % take; + for (var i = 0; i < jsonDataIterations; i+= take) { var data = await sqlite.Set().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).AsAsyncEnumerable() .SelectAwait(async x => new JsonEntity