The job list showed a bar and a free-text line that each handler worded its own way. Each handler now reports its step, the item it is on, photo x of y and sequence/folder/output/step n of m through the P2.1 JobContext detail. Clients can word and lay that out themselves, and the 2/s throttle keeps the cost low: counts within a step go through ReportItemAsync, which allocates nothing. - scan: List, then Index (folder n of m, photo x of y as an adopted or reconciled folder is read) or Check, then FollowUps - verify, thumbs, proxies, deep analysis: photo x of y of sequence n of m; light analysis: sequence n of m; a thumbnail/proxy checkpoint carries the frame count it saves - convert: Verify (resume), Convert photo x of y, Replace; reorganize: step n of m with the title; import: the file being copied, photo x of y - maintenance: the step key, step n of 5, then Check; duplicates, orphans and backup run with no count; cleanup names step n of m; empty trash: entry n of m - render (local, workspace, render node): Analyse, Encode (frames of the last output, output n of m in a batch), Verify; sync, video copy, workspace copy/send/move: Upload/Download/CopyProxy/CopyOriginal/ CopyVideo/Reorganize with their items and counts The detail carries keys and names only, never localized text. The existing Message strings stay for clients that still show them. Refs #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using Chronos.Core.Model;
|
|
using Chronos.Data.Jobs;
|
|
|
|
namespace Chronos.Data.Tests.Jobs;
|
|
|
|
/// <summary>
|
|
/// Every progress report a job engine publishes, kept to tell which details a handler sent and in what order (owner review
|
|
/// 5, #65). The engine it records has no publish throttle (<see cref="Options"/>), so each report a handler makes goes out.
|
|
/// </summary>
|
|
internal sealed class DetailRecorder
|
|
{
|
|
private readonly List<JobProgressInfo> _published = [];
|
|
|
|
/// <summary>A started engine's options that publish every report: one worker, fast polls and checkpoints, no progress interval.</summary>
|
|
public static JobEngineOptions Options(string worker = "detail") => new()
|
|
{
|
|
Workers = 1,
|
|
WorkerId = worker,
|
|
PollInterval = TimeSpan.FromMilliseconds(50),
|
|
CheckpointInterval = TimeSpan.FromMilliseconds(50),
|
|
ProgressInterval = TimeSpan.Zero,
|
|
};
|
|
|
|
/// <summary>A new engine with <paramref name="handlers"/>, recorded, not started.</summary>
|
|
public JobEngine Engine(ChronosDatabase db, IEnumerable<IJobHandler> handlers, string worker = "detail")
|
|
{
|
|
var engine = new JobEngine(db, [.. handlers], Options(worker));
|
|
engine.Progress += p =>
|
|
{
|
|
lock (_published) _published.Add(p);
|
|
};
|
|
return engine;
|
|
}
|
|
|
|
/// <summary>The reports of <paramref name="jobId"/> in the order they went out.</summary>
|
|
public IReadOnlyList<JobProgressInfo> Of(Guid jobId)
|
|
{
|
|
lock (_published) return [.. _published.Where(p => p.JobId == jobId)];
|
|
}
|
|
|
|
/// <summary>The details of <paramref name="jobId"/>, without repeats of the one before.</summary>
|
|
public IReadOnlyList<JobDetail> Details(Guid jobId)
|
|
{
|
|
var details = new List<JobDetail>();
|
|
foreach (var report in Of(jobId))
|
|
{
|
|
if (report.Detail is { } detail && (details.Count == 0 || details[^1] != detail)) details.Add(detail);
|
|
}
|
|
return details;
|
|
}
|
|
|
|
/// <summary>The steps of <paramref name="jobId"/> in order, each once in a row.</summary>
|
|
public IReadOnlyList<JobStep> Steps(Guid jobId)
|
|
{
|
|
var steps = new List<JobStep>();
|
|
foreach (var detail in Details(jobId))
|
|
{
|
|
if (steps.Count == 0 || steps[^1] != detail.Step) steps.Add(detail.Step);
|
|
}
|
|
return steps;
|
|
}
|
|
}
|