Added English voice work updater.

This commit is contained in:
2025-10-23 10:07:50 -04:00
parent 3a115bc7b8
commit 36fcd5379a
19 changed files with 651 additions and 401 deletions

View File

@@ -3,7 +3,6 @@ using JSMR.Application.Integrations.DLSite.Models;
using JSMR.Application.Integrations.Ports;
using JSMR.Application.Scanning.Contracts;
using JSMR.Application.Scanning.Ports;
using JSMR.Application.VoiceWorks.Ports;
using Microsoft.Extensions.DependencyInjection;
namespace JSMR.Application.Scanning;
@@ -12,14 +11,14 @@ public sealed class ScanVoiceWorksHandler(
IServiceProvider serviceProvider,
IDLSiteClient dlsiteClient,
ISpamCircleCache spamCircleCache,
IVoiceWorkWriter writer,
IVoiceWorkSearchUpdater searchUpdater)
{
public async Task<ScanVoiceWorksResponse> HandleAsync(ScanVoiceWorksRequest request, CancellationToken cancellationToken)
{
IVoiceWorksScanner? scanner = serviceProvider.GetKeyedService<IVoiceWorksScanner>(request.Locale);
IVoiceWorkUpdater? updater = serviceProvider.GetKeyedService<IVoiceWorkUpdater>(request.Locale);
if (scanner is null)
if (scanner is null || updater is null)
return new();
VoiceWorkScanOptions options = new(
@@ -41,10 +40,10 @@ public sealed class ScanVoiceWorksHandler(
VoiceWorkIngest[] ingests = [.. works.Select(work =>
{
voiceWorkDetails.TryGetValue(work.ProductId!, out VoiceWorkDetails? value);
return new VoiceWorkIngest(work, value);
return VoiceWorkIngest.From(work, value);
})];
int[] voiceWorkIds = await writer.UpsertAsync(ingests, cancellationToken);
int[] voiceWorkIds = await updater.UpsertAsync(ingests, cancellationToken);
await searchUpdater.UpdateAsync(voiceWorkIds, cancellationToken);
return new();