Updated worker to show upsert issue messages.
This commit is contained in:
@@ -10,6 +10,8 @@ public interface IVoiceWorkUpdater
|
||||
|
||||
public class VoiceWorkUpsertResult
|
||||
{
|
||||
public string ProductId { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public int? VoiceWorkId { get; set; }
|
||||
public VoiceWorkStatus UpdateStatus { get; set; }
|
||||
public ICollection<VoiceWorkUpsertIssue> Issues { get; } = [];
|
||||
|
||||
@@ -47,11 +47,11 @@ public static class InfrastructureServiceCollectionExtensions
|
||||
|
||||
services.AddKeyedScoped<IVoiceWorksScanner, JapaneseVoiceWorksScanner>(Locale.Japanese);
|
||||
services.AddKeyedScoped<IVoiceWorksScanner, EnglishVoiceWorksScanner>(Locale.English);
|
||||
services.AddSingleton<IVoiceWorkScannerRepository, VoiceWorkScannerRepository>();
|
||||
services.AddScoped<IVoiceWorkScannerRepository, VoiceWorkScannerRepository>();
|
||||
|
||||
services.AddKeyedScoped<IVoiceWorkUpdater, VoiceWorkUpdater>(Locale.Japanese);
|
||||
services.AddKeyedScoped<IVoiceWorkUpdater, EnglishVoiceWorkUpdater>(Locale.English);
|
||||
services.AddSingleton<IVoiceWorkUpdaterRepository, VoiceWorkUpdaterRepository>();
|
||||
services.AddScoped<IVoiceWorkUpdaterRepository, VoiceWorkUpdaterRepository>();
|
||||
|
||||
services.AddScoped<IVoiceWorkSearchUpdater, VoiceWorkSearchUpdater>();
|
||||
|
||||
|
||||
@@ -56,6 +56,10 @@ public class EnglishVoiceWorkUpdater(AppDbContext dbContext, ILanguageIdentifier
|
||||
Results: productIds.ToDictionary(
|
||||
productId => productId,
|
||||
productId => new VoiceWorkUpsertResult()
|
||||
{
|
||||
ProductId = productId,
|
||||
Title = ingests.First(x => x.ProductId == productId).Title
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -87,6 +87,10 @@ public class VoiceWorkUpdater(AppDbContext dbContext, ITimeProvider timeProvider
|
||||
Results: productIds.ToDictionary(
|
||||
productId => productId,
|
||||
productId => new VoiceWorkUpsertResult()
|
||||
{
|
||||
ProductId = productId,
|
||||
Title = ingests.First(x => x.ProductId == productId).Title
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.CommandLine;
|
||||
using System.Text;
|
||||
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
@@ -16,10 +17,13 @@ builder.Configuration
|
||||
.SetBasePath(builder.Environment.ContentRootPath)
|
||||
.AddJsonFile("appsettings.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();
|
||||
|
||||
if (builder.Environment.IsDevelopment())
|
||||
{
|
||||
builder.Configuration.AddUserSecrets(typeof(Program).Assembly, optional: true);
|
||||
}
|
||||
|
||||
// Pull the connection string from config (appsettings or secrets or env)
|
||||
string connectionString = builder.Configuration.GetConnectionString("AppDb")
|
||||
?? throw new InvalidOperationException("Missing ConnectionStrings:AppDb");
|
||||
@@ -137,4 +141,6 @@ schemaDumpCommand.SetAction(async (parseResult, cancellationToken) =>
|
||||
|
||||
rootCommand.Add(schemaDumpCommand);
|
||||
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
return await rootCommand.Parse(args).InvokeAsync();
|
||||
@@ -77,14 +77,20 @@ public sealed class PagedScanRunner(
|
||||
IEnumerable<VoiceWorkUpsertResult> resultsWithIssues = response.Results.Where(x => x.Issues.Count > 0);
|
||||
|
||||
// TODO: Later
|
||||
//foreach (VoiceWorkUpsertResult resultWithIssues in resultsWithIssues)
|
||||
//{
|
||||
foreach (VoiceWorkUpsertResult resultWithIssues in resultsWithIssues)
|
||||
{
|
||||
//log.LogWarning($"PRoblem with {resultWithIssues.}")
|
||||
//string messageToDisplay = $"{scannedVoiceWork.ProductId} - {scannedVoiceWork.ProductName} -- {message}";
|
||||
|
||||
//Console.WriteLine(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
|
||||
await checkpoints.SaveLastPageAsync(options.Locale, currentPage, cancellationToken);
|
||||
|
||||
@@ -30,6 +30,26 @@ public static class CliUi
|
||||
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) =>
|
||||
AnsiConsole.MarkupLine($"[yellow]⚠ {Escape(message)}[/]");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user