Updated worker to show upsert issue messages.
All checks were successful
ci / build-test (push) Successful in 2m36s
ci / publish-image (push) Has been skipped

This commit is contained in:
2026-03-07 00:03:18 -05:00
parent 1d40013837
commit 1e01edf1b7
7 changed files with 53 additions and 11 deletions

View File

@@ -10,6 +10,8 @@ public interface IVoiceWorkUpdater
public class VoiceWorkUpsertResult public class VoiceWorkUpsertResult
{ {
public string ProductId { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public int? VoiceWorkId { get; set; } public int? VoiceWorkId { get; set; }
public VoiceWorkStatus UpdateStatus { get; set; } public VoiceWorkStatus UpdateStatus { get; set; }
public ICollection<VoiceWorkUpsertIssue> Issues { get; } = []; public ICollection<VoiceWorkUpsertIssue> Issues { get; } = [];

View File

@@ -47,11 +47,11 @@ public static class InfrastructureServiceCollectionExtensions
services.AddKeyedScoped<IVoiceWorksScanner, JapaneseVoiceWorksScanner>(Locale.Japanese); services.AddKeyedScoped<IVoiceWorksScanner, JapaneseVoiceWorksScanner>(Locale.Japanese);
services.AddKeyedScoped<IVoiceWorksScanner, EnglishVoiceWorksScanner>(Locale.English); services.AddKeyedScoped<IVoiceWorksScanner, EnglishVoiceWorksScanner>(Locale.English);
services.AddSingleton<IVoiceWorkScannerRepository, VoiceWorkScannerRepository>(); services.AddScoped<IVoiceWorkScannerRepository, VoiceWorkScannerRepository>();
services.AddKeyedScoped<IVoiceWorkUpdater, VoiceWorkUpdater>(Locale.Japanese); services.AddKeyedScoped<IVoiceWorkUpdater, VoiceWorkUpdater>(Locale.Japanese);
services.AddKeyedScoped<IVoiceWorkUpdater, EnglishVoiceWorkUpdater>(Locale.English); services.AddKeyedScoped<IVoiceWorkUpdater, EnglishVoiceWorkUpdater>(Locale.English);
services.AddSingleton<IVoiceWorkUpdaterRepository, VoiceWorkUpdaterRepository>(); services.AddScoped<IVoiceWorkUpdaterRepository, VoiceWorkUpdaterRepository>();
services.AddScoped<IVoiceWorkSearchUpdater, VoiceWorkSearchUpdater>(); services.AddScoped<IVoiceWorkSearchUpdater, VoiceWorkSearchUpdater>();

View File

@@ -56,6 +56,10 @@ public class EnglishVoiceWorkUpdater(AppDbContext dbContext, ILanguageIdentifier
Results: productIds.ToDictionary( Results: productIds.ToDictionary(
productId => productId, productId => productId,
productId => new VoiceWorkUpsertResult() productId => new VoiceWorkUpsertResult()
{
ProductId = productId,
Title = ingests.First(x => x.ProductId == productId).Title
}
) )
); );

View File

@@ -87,6 +87,10 @@ public class VoiceWorkUpdater(AppDbContext dbContext, ITimeProvider timeProvider
Results: productIds.ToDictionary( Results: productIds.ToDictionary(
productId => productId, productId => productId,
productId => new VoiceWorkUpsertResult() productId => new VoiceWorkUpsertResult()
{
ProductId = productId,
Title = ingests.First(x => x.ProductId == productId).Title
}
) )
); );

View File

@@ -8,6 +8,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System.CommandLine; using System.CommandLine;
using System.Text;
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
@@ -16,10 +17,13 @@ builder.Configuration
.SetBasePath(builder.Environment.ContentRootPath) .SetBasePath(builder.Environment.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true)
// Add user secrets (works regardless of environment when optional: true)
.AddUserSecrets(typeof(Program).Assembly, optional: true)
.AddEnvironmentVariables(); .AddEnvironmentVariables();
if (builder.Environment.IsDevelopment())
{
builder.Configuration.AddUserSecrets(typeof(Program).Assembly, optional: true);
}
// Pull the connection string from config (appsettings or secrets or env) // Pull the connection string from config (appsettings or secrets or env)
string connectionString = builder.Configuration.GetConnectionString("AppDb") string connectionString = builder.Configuration.GetConnectionString("AppDb")
?? throw new InvalidOperationException("Missing ConnectionStrings:AppDb"); ?? throw new InvalidOperationException("Missing ConnectionStrings:AppDb");
@@ -137,4 +141,6 @@ schemaDumpCommand.SetAction(async (parseResult, cancellationToken) =>
rootCommand.Add(schemaDumpCommand); rootCommand.Add(schemaDumpCommand);
Console.OutputEncoding = Encoding.UTF8;
return await rootCommand.Parse(args).InvokeAsync(); return await rootCommand.Parse(args).InvokeAsync();

View File

@@ -77,14 +77,20 @@ public sealed class PagedScanRunner(
IEnumerable<VoiceWorkUpsertResult> resultsWithIssues = response.Results.Where(x => x.Issues.Count > 0); IEnumerable<VoiceWorkUpsertResult> resultsWithIssues = response.Results.Where(x => x.Issues.Count > 0);
// TODO: Later // TODO: Later
//foreach (VoiceWorkUpsertResult resultWithIssues in resultsWithIssues) foreach (VoiceWorkUpsertResult resultWithIssues in resultsWithIssues)
//{ {
//log.LogWarning($"PRoblem with {resultWithIssues.}") //log.LogWarning($"PRoblem with {resultWithIssues.}")
//string messageToDisplay = $"{scannedVoiceWork.ProductId} - {scannedVoiceWork.ProductName} -- {message}"; //string messageToDisplay = $"{scannedVoiceWork.ProductId} - {scannedVoiceWork.ProductName} -- {message}";
//Console.WriteLine(messageToDisplay); //Console.WriteLine(messageToDisplay);
//messages.Add(messageToDisplay); //messages.Add(messageToDisplay);
//}
string productId = resultWithIssues.ProductId;
string title = resultWithIssues.Title;
string[] messages = [.. resultWithIssues.Issues.Select(x => x.Message)];
CliUi.PageErrors($"{productId} - {title}", messages);
}
// Save checkpoint // Save checkpoint
await checkpoints.SaveLastPageAsync(options.Locale, currentPage, cancellationToken); await checkpoints.SaveLastPageAsync(options.Locale, currentPage, cancellationToken);

View File

@@ -30,6 +30,26 @@ public static class CliUi
AnsiConsole.Write(panel); AnsiConsole.Write(panel);
} }
public static void PageErrors(string productId, string[] messages)
{
if (messages.Length == 0)
return;
var grid = new Grid().AddColumn();
foreach (string message in messages )
{
grid.AddRow($"[red]{Escape(message)}[/]");
}
var panel = new Panel(grid)
.Header($"[bold]{productId}[/]")
.Border(BoxBorder.Rounded)
.Padding(1, 0, 1, 0);
AnsiConsole.Write(panel);
}
public static void Warning(string message) => public static void Warning(string message) =>
AnsiConsole.MarkupLine($"[yellow]⚠ {Escape(message)}[/]"); AnsiConsole.MarkupLine($"[yellow]⚠ {Escape(message)}[/]");