diff --git a/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj b/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj
index a66fcf9d..ef9e6a0a 100644
--- a/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj
+++ b/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj
@@ -9,7 +9,7 @@
true
$(NoWarn);1591
-
+
$(DefineConstants);BANNERLORDBUTRMODULEMANAGER_NULLABLE
@@ -78,4 +78,4 @@
-
+
\ No newline at end of file
diff --git a/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs b/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs
index 3dc86ea8..f83beaf7 100644
--- a/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs
+++ b/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs
@@ -7,7 +7,6 @@
using BUTR.Site.NexusMods.Server.Options;
using BUTR.Site.NexusMods.Server.Services;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -58,7 +57,7 @@ public CrashReportProcessorJob(ILogger logger, IService
private static async Task FilterCrashReportsAsync(TenantId tenant,
IServiceProvider serviceProvider,
- IAsyncEnumerable requests,
+ IEnumerable requests,
ChannelWriter toDownloadChannel,
ChannelWriter linkedCrashReportsChannel,
ChannelWriter ignoredCrashReportsChannel,
@@ -190,8 +189,8 @@ private static async Task WriteIgnoredToDatabaseAsync(
{
var dbContextFactory = serviceProvider.GetRequiredService();
var dbContextWrite = await dbContextFactory.CreateWriteAsync(ct);
- await foreach (var entity in ignoredCrashReportsChannel.ReadAllAsync(ct))
- dbContextWrite.CrashReportIgnoredFileIds.Add(entity);
+ var entries = await ignoredCrashReportsChannel.ReadAllAsync(ct).ToArrayAsync(ct);
+ dbContextWrite.FutureUpsert(x => x.CrashReportIgnoredFileIds, entries);
await dbContextWrite.SaveAsync(ct);
}
@@ -203,8 +202,8 @@ private static async Task WriteLinkedToDatabaseAsync(
{
var dbContextFactory = serviceProvider.GetRequiredService();
var dbContextWrite = await dbContextFactory.CreateWriteAsync(ct);
- await foreach (var entity in linkedCrashReportsChannel.ReadAllAsync(ct))
- dbContextWrite.CrashReportToFileIds.Add(entity);
+ var entries = await linkedCrashReportsChannel.ReadAllAsync(ct).ToArrayAsync(ct);
+ dbContextWrite.FutureUpsert(x => x.CrashReportToFileIds, entries);
await dbContextWrite.SaveAsync(ct);
}
@@ -305,7 +304,7 @@ static string GetException(ExceptionModel? exception, bool inner = false) => exc
// Disposing the DBContext will save the data
}
- private static async Task HandleFileIdDatesAsync(TenantId tenant, IServiceProvider serviceProvider, ILogger logger, CrashReporterClient client, IAsyncEnumerable requests, CancellationToken ct)
+ private static async Task HandleFileIdDatesAsync(TenantId tenant, IServiceProvider serviceProvider, ILogger logger, CrashReporterClient client, IEnumerable requests, CancellationToken ct)
{
var options = serviceProvider.GetRequiredService>().Value;
var toDownloadChannel = Channel.CreateBounded(ParallelCount);
@@ -339,6 +338,7 @@ public async Task Execute(IJobExecutionContext context)
await foreach (var batch in client.GetNewCrashReportMetadatasAsync(DateTime.UtcNow.AddHours(-2), ct).OfType().ChunkAsync(100).WithCancellation(ct))
{
+ await HandleFileIdDatesAsync(tenant, scope.ServiceProvider, _logger, client, batch, ct);
processed += batch.Count;
}
}