Updated scanner/upsert logic.
This commit is contained in:
@@ -3,11 +3,17 @@ 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;
|
||||
|
||||
public sealed class ScanVoiceWorksHandler(IServiceProvider serviceProvider, IDLSiteClient dlsiteClient, ISpamCircleCache spamCircleCache)
|
||||
public sealed class ScanVoiceWorksHandler(
|
||||
IServiceProvider serviceProvider,
|
||||
IDLSiteClient dlsiteClient,
|
||||
ISpamCircleCache spamCircleCache,
|
||||
IVoiceWorkWriter writer,
|
||||
IVoiceWorkSearchUpdater searchUpdater)
|
||||
{
|
||||
public async Task<ScanVoiceWorksResponse> HandleAsync(ScanVoiceWorksRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -32,21 +38,14 @@ public sealed class ScanVoiceWorksHandler(IServiceProvider serviceProvider, IDLS
|
||||
string[] productIds = [.. works.Where(x => !string.IsNullOrWhiteSpace(x.ProductId)).Select(x => x.ProductId!)];
|
||||
VoiceWorkDetailCollection voiceWorkDetails = await dlsiteClient.GetVoiceWorkDetailsAsync(productIds, cancellationToken);
|
||||
|
||||
// TODO
|
||||
|
||||
/*
|
||||
var ingests = works.Select(VoiceWorkIngest.From).ToList();
|
||||
var upsert = await _writer.UpsertAsync(ingests, ct);
|
||||
|
||||
// only update search text for affected rows
|
||||
await _search.UpdateAsync(upsert.AffectedVoiceWorkIds, ct);
|
||||
|
||||
return new ScanVoiceWorksResponse
|
||||
List<VoiceWorkIngest> ingests = [.. works.Select(work =>
|
||||
{
|
||||
Inserted = upsert.Inserted,
|
||||
Updated = upsert.Updated
|
||||
};
|
||||
*/
|
||||
voiceWorkDetails.TryGetValue(work.ProductId!, out VoiceWorkDetails? value);
|
||||
return new VoiceWorkIngest(work, value);
|
||||
})];
|
||||
|
||||
int[] voiceWorkIds = await writer.UpsertAsync(ingests, cancellationToken);
|
||||
await searchUpdater.UpdateAsync(voiceWorkIds, cancellationToken);
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user