feat(data): filter sequences by renders and sync state; read a remote sequence's first frame alone
SequenceQuery.Rendered and SyncStates back the Library's Rendered, Not rendered and Synced status choices. ISyncRemote.FirstFrameAsync reads one row of the frames page (default: the whole list), so a remote card without a hero frame no longer downloads the server's manifest for its thumbnail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
4 files changed
+31
-2
No files matched your search
@@ -35,6 +35,12 @@ public sealed record SequenceQuery
|
||||
|
||||
public string? Tag { get; init; }
|
||||
|
||||
/// <summary>True: with at least one render; false: without any; null: either.</summary>
|
||||
public bool? Rendered { get; init; }
|
||||
|
||||
/// <summary>Sync states of which the sequence must be in one; null or empty: any.</summary>
|
||||
public IReadOnlyCollection<SyncState>? SyncStates { get; init; }
|
||||
|
||||
/// <summary>Case-insensitive substring of the title, camera make/model or a tag.</summary>
|
||||
public string? Text { get; init; }
|
||||
|
||||
@@ -385,6 +391,8 @@ public sealed class SequenceRepository
|
||||
where.Add($"(s.status & {mask}) = {mask}");
|
||||
}
|
||||
if (query.WithoutStatus != SequenceStatus.None) where.Add($"(s.status & {p.Add((int)query.WithoutStatus)}) = 0");
|
||||
if (query.Rendered is { } rendered) where.Add(rendered ? "s.rendered_count > 0" : "s.rendered_count = 0");
|
||||
if (query.SyncStates is { Count: > 0 } states) where.Add($"s.sync_state IN ({string.Join(", ", states.Select(state => p.Add((int)state)))})");
|
||||
if (query.Tag is { } tag)
|
||||
where.Add("EXISTS (SELECT 1 FROM sequence_tags st JOIN tags t ON t.id = st.tag_id " +
|
||||
$"WHERE st.sequence_id = s.id AND t.name_key = {p.Add(TagRepository.Key(tag))})");
|
||||
|
||||
@@ -23,6 +23,10 @@ public interface ISyncRemote : IDisposable
|
||||
/// <summary>Every frame row of a sequence, in index order.</summary>
|
||||
Task<IReadOnlyList<FrameDto>> ListFramesAsync(Guid sequenceId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>The first frame row of a sequence (its thumbnail stands for a sequence without a hero frame); null when it has none yet.</summary>
|
||||
async Task<FrameDto?> FirstFrameAsync(Guid sequenceId, CancellationToken cancellationToken) =>
|
||||
(await ListFramesAsync(sequenceId, cancellationToken).ConfigureAwait(false)).FirstOrDefault();
|
||||
|
||||
/// <summary>A 409 <see cref="TitanoApiException"/> means the settings version moved on the server.</summary>
|
||||
Task<SequenceDto> UpdateSequenceAsync(Guid id, UpdateSequenceRequest request, CancellationToken cancellationToken);
|
||||
|
||||
@@ -98,6 +102,10 @@ public sealed class TitanoSyncRemote(TitanoClient client, bool ownsClient) : ISy
|
||||
return all;
|
||||
}
|
||||
|
||||
/// <summary>One row of the first frames page instead of the whole list.</summary>
|
||||
public async Task<FrameDto?> FirstFrameAsync(Guid sequenceId, CancellationToken cancellationToken) =>
|
||||
(await client.ListFramesAsync(sequenceId, null, 1, cancellationToken).ConfigureAwait(false)).Items.FirstOrDefault();
|
||||
|
||||
public Task<SequenceDto> UpdateSequenceAsync(Guid id, UpdateSequenceRequest request, CancellationToken cancellationToken) =>
|
||||
client.UpdateSequenceAsync(id, request, cancellationToken);
|
||||
|
||||
|
||||
@@ -96,8 +96,14 @@ public abstract class CatalogRepositoryTests(TestContext context) : RepositoryTe
|
||||
await db.Archives.UpsertAsync(main, Ct);
|
||||
await db.Archives.UpsertAsync(other, Ct);
|
||||
var owner = Guid.CreateVersion7();
|
||||
var harbour = TestData.Sequence(main.Id, new DateTime(2024, 6, 1), "Porto di CITTÀ vecchia") with { Status = SequenceStatus.AnalyzedLight, Tags = ["sea"] };
|
||||
var stars = TestData.Sequence(main.Id, new DateTime(2025, 1, 2), "Milky way", "Z8") with { CameraMake = "Nikon", Tags = ["Night Sky"], OwnerUserId = owner };
|
||||
var harbour = TestData.Sequence(main.Id, new DateTime(2024, 6, 1), "Porto di CITTÀ vecchia") with
|
||||
{
|
||||
Status = SequenceStatus.AnalyzedLight, Tags = ["sea"], RenderedCount = 2,
|
||||
};
|
||||
var stars = TestData.Sequence(main.Id, new DateTime(2025, 1, 2), "Milky way", "Z8") with
|
||||
{
|
||||
CameraMake = "Nikon", Tags = ["Night Sky"], OwnerUserId = owner, Origin = SequenceOrigin.Server, SyncState = SyncState.LocalAhead,
|
||||
};
|
||||
var clouds = TestData.Sequence(main.Id, new DateTime(2024, 12, 31, 23, 59, 59), "50%_clouds") with { Status = SequenceStatus.AnalyzedLight | SequenceStatus.Verified };
|
||||
var elsewhere = TestData.Sequence(other.Id, new DateTime(2024, 3, 3), "Elsewhere");
|
||||
var undated = TestData.Sequence(main.Id, null, "Undated");
|
||||
@@ -111,6 +117,10 @@ public abstract class CatalogRepositoryTests(TestContext context) : RepositoryTe
|
||||
Assert.SequenceEqual(["50%_clouds", "Porto di CITTÀ vecchia"], await Titles(new() { WithStatus = SequenceStatus.AnalyzedLight }));
|
||||
Assert.SequenceEqual(["Porto di CITTÀ vecchia"], await Titles(new() { WithStatus = SequenceStatus.AnalyzedLight, WithoutStatus = SequenceStatus.Verified }));
|
||||
Assert.SequenceEqual(["Milky way"], await Titles(new() { Tag = " night SKY " }));
|
||||
Assert.SequenceEqual(["Porto di CITTÀ vecchia"], await Titles(new() { Rendered = true }));
|
||||
Assert.SequenceEqual(["50%_clouds", "Elsewhere", "Milky way", "Undated"], await Titles(new() { Rendered = false }));
|
||||
Assert.SequenceEqual(["Milky way"], await Titles(new() { SyncStates = [SyncState.InSync, SyncState.LocalAhead] }));
|
||||
Assert.Equal(5, (await Titles(new() { SyncStates = [] })).Length);
|
||||
Assert.SequenceEqual(["Porto di CITTÀ vecchia"], await Titles(new() { Text = "città" }));
|
||||
Assert.SequenceEqual(["Milky way"], await Titles(new() { Text = "NIKON" }));
|
||||
Assert.SequenceEqual(["Milky way"], await Titles(new() { Text = "ght sk" }));
|
||||
|
||||
@@ -170,6 +170,9 @@ public sealed class SyncServerTests(TestContext context)
|
||||
var remoteId = (await studio.EntryAsync("Milan skyline dusk")).Link!.RemoteId;
|
||||
await ServerIdleAsync(server);
|
||||
Assert.True(((await server.Database.Sequences.GetAsync(remoteId))!.Status & SequenceStatus.ThumbsBuilt) != 0, "thumbnails on the server");
|
||||
// A remote card without a hero frame shows its first frame, read as one row instead of the whole list.
|
||||
ISyncRemote remote = laptop.Remote;
|
||||
Assert.Equal((await remote.ListFramesAsync(remoteId, context.Cancellation))[0].Id, (await remote.FirstFrameAsync(remoteId, context.Cancellation))?.Id);
|
||||
|
||||
await laptop.Sync.RefreshAsync(laptop.Remote, new SyncPolicy(), context.Cancellation);
|
||||
var job = await laptop.Sync.EnqueueDownloadAsync(laptop.Engine, laptop.Server, remoteId, "Milan skyline dusk", SyncDownloadMode.Proxies, null);
|
||||
|
||||
Reference in new issue
Block a user