fix(analysis): follow-ups skip queued sequences; photos added by a scan are analysed again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+75
-10
No files matched your search
@@ -60,6 +60,61 @@ public sealed class AnalysisFollowUpTests(TestContext context)
|
||||
Assert.True((await fx.Db.Sequences.GetAsync(sequenceId.Value, fx.Ct))!.Status.HasFlag(SequenceStatus.AnalyzedLight), "analysed");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PhotosAddedToAnAnalysedFolderAreAnalysedAgain()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { FrameCount = 12 }), "Roof");
|
||||
await fx.StartEngineAsync(withArchive: true);
|
||||
var first = await fx.EnqueueAsync(Titano.Data.Processing.ProcessingJobs.LightAnalysis([sequence.Id]));
|
||||
await fx.WaitForAsync(first.Id, JobState.Done);
|
||||
|
||||
// The camera kept shooting into the folder: the next scan indexes the new photos and analyses the sequence again.
|
||||
fx.Write(SyntheticSequence.Create(new SyntheticSequenceOptions { FrameCount = 18 }), "Roof", first: 12);
|
||||
var scan = await fx.EnqueueAsync(ArchiveJobs.Scan(fx.Archive.Archive));
|
||||
await fx.WaitForAsync(scan.Id, JobState.Done);
|
||||
var again = (await fx.Db.Jobs.ListAsync(null, JobKind.LightAnalyse, cancellationToken: fx.Ct)).Items.Single(j => j.Id != first.Id);
|
||||
await fx.WaitForAsync(again.Id, JobState.Done);
|
||||
|
||||
var analysed = (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!;
|
||||
Assert.Equal(18, analysed.FrameCount);
|
||||
Assert.True(analysed.Status.HasFlag(SequenceStatus.AnalyzedLight), "analysed again");
|
||||
Assert.True(ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Status.HasFlag(SequenceStatus.AnalyzedLight), "sidecar status");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceWaitingForLightAnalysisIsNotQueuedAgain()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { FrameCount = 12 }), "Roof");
|
||||
// Queued before the scan, which runs first (user priority) and finds the sequence not analysed yet.
|
||||
var waiting = await QueueAsync(fx, Titano.Data.Processing.ProcessingJobs.LightAnalysis([sequence.Id]));
|
||||
var scan = await QueueAsync(fx, ArchiveJobs.Scan(fx.Archive.Archive, full: true));
|
||||
await fx.StartEngineAsync(withArchive: true);
|
||||
|
||||
await fx.WaitForAsync(scan.Id, JobState.Done);
|
||||
await fx.WaitForAsync(waiting.Id, JobState.Done);
|
||||
Assert.Equal(waiting.Id, (await SingleLightJobAsync(fx))?.Id);
|
||||
}
|
||||
|
||||
/// <summary>Queues a job before the engine starts.</summary>
|
||||
private static async Task<Job> QueueAsync(ProcessingFixture fx, Titano.Data.Archiving.Jobs.ArchiveJobRequest request)
|
||||
{
|
||||
var job = new Job
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Kind = request.Kind,
|
||||
TargetIds = request.Targets,
|
||||
TargetLabel = request.Label,
|
||||
ParametersJson = request.ParametersJson,
|
||||
Priority = request.Priority,
|
||||
State = JobState.Queued,
|
||||
Created = DateTimeOffset.UtcNow,
|
||||
};
|
||||
await fx.Db.Jobs.EnqueueAsync(job, fx.Ct);
|
||||
return job;
|
||||
}
|
||||
|
||||
private static async Task<Job?> SingleLightJobAsync(ProcessingFixture fx) =>
|
||||
(await fx.Db.Jobs.ListAsync(null, JobKind.LightAnalyse, cancellationToken: fx.Ct)).Items.SingleOrDefault();
|
||||
}
|
||||
Reference in new issue
Block a user