E3: prove web, interfaccia, demo e scala di formati e fotogrammi
Le prove dell'API dei fotogrammi (anteprime, istanti, «Scarica» di un'immagine o di uno zip con nomi e date, limiti, il permesso dei lavori lunghi, i fotogrammi nella cartella delle copie, i controlli dell'Origin) e dei formati («Copia in…» con il suo formato, la conversione della libreria dalla domanda alla cancellazione). Le prove dell'interfaccia con Chromium: formati delle impostazioni e della cartella, la domanda «Solo i nuovi», «Cambia» in «Copia in…», «Fotogrammi…» dal visualizzatore e da una scelta, le righe delle copie e del file convertito. Ciò che le pagine devono dire si chiede all'API, perché la demo dispone i suoi elementi secondo l'ora. La prova di scala riempie anche copie convertite e fotogrammi, che il filtro «Copie» deve contare o ignorare come prima, entro i suoi tempi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f5e12c5d74
commit
d197715fc7
6 files changed
+1292
-19
No files matched your search
@@ -83,6 +83,9 @@ public sealed class LibraryScaleTests
|
||||
var copies = await FillCopiesAsync(db, temp, accountIds, ct);
|
||||
fill.Stop();
|
||||
TestContext.WriteLine($"Riempimento: {Entries:N0} elementi in {fill.Elapsed.TotalSeconds:F1} s");
|
||||
TestContext.WriteLine($"Copie: {copies.Copied:N0} copiate (di cui {copies.Converted:N0} convertite), {copies.Removed:N0} tolte, {copies.Superseded:N0} superate, {copies.Frames:N0} fotogrammi, su {copies.Due:N0} file da copiare");
|
||||
Assert.IsGreaterThan(0, copies.Converted, "converted copies in the fill");
|
||||
Assert.IsGreaterThan(0, copies.Frames, "frames in the fill");
|
||||
|
||||
// Plans differ with and without ANALYZE statistics: both must be fast.
|
||||
// The fill stays outside the timings.
|
||||
@@ -111,26 +114,46 @@ public sealed class LibraryScaleTests
|
||||
|
||||
var destination = $"(CASE e.account_id WHEN {accountIds[OwnAccount]} THEN {own.Id} ELSE {general.Id} END)";
|
||||
var due = $"m.sha256 IS NOT NULL AND e.account_id <> {accountIds[OffAccount]} AND (e.account_id <> {accountIds[OwnAccount]} OR m.kind = 'Photo')";
|
||||
int Insert(WriteContext w, string state, string source, string supersededBy, string which) => w.Command(
|
||||
$"""
|
||||
INSERT INTO export_copy (destination_id, account_id, media_id, source_sha256, variant, format, state, superseded_by_sha256,
|
||||
origin, relative_path, bytes, copy_sha256, copied_at)
|
||||
SELECT {destination}, e.account_id, m.id, {source}, 'Whole', 'Original', '{state}', {supersededBy},
|
||||
'Written', 'p/' || m.id || '.jpg', 1000, {source}, 1767225600000
|
||||
FROM media m JOIN entry e ON e.id = m.entry_id
|
||||
WHERE {due} AND {which}
|
||||
""").ExecuteNonQuery();
|
||||
int Insert(WriteContext w, string state, string source, string supersededBy, string which, Form? form = null)
|
||||
{
|
||||
var f = form ?? Form.Whole;
|
||||
return w.Command(
|
||||
$"""
|
||||
INSERT INTO export_copy (destination_id, account_id, media_id, source_sha256, variant, format, frame_at_ms, state, superseded_by_sha256,
|
||||
origin, relative_path, bytes, copy_sha256, copied_at)
|
||||
SELECT {destination}, e.account_id, m.id, {source}, '{f.Variant}', {f.Format}, {f.FrameAt}, '{state}', {supersededBy},
|
||||
'Written', 'p/' || m.id || '{f.Suffix}', 1000, {f.CopySha ?? source}, 1767225600000
|
||||
FROM media m JOIN entry e ON e.id = m.entry_id
|
||||
WHERE {due} AND {which}
|
||||
""").ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// Tappa E3: three in ten of the copied files are converted copies (PNG, or MP4 for a video), which count as
|
||||
// copied; one video in fifty has a frame in its folder, copied or not, and one in a hundred a frame «Tolto»:
|
||||
// frames never count in the «Copie» filter (D4), so the counts asserted stay those of the whole copies.
|
||||
var converted = new Form("Converted", "(CASE m.kind WHEN 'Video' THEN 'Mp4' ELSE 'Png' END)", "NULL", ".c", "'c' || substr(m.sha256, 2)");
|
||||
var frame = new Form("Frame", "'Png'", "1000", "_t0m01s000.png", "'f' || substr(m.sha256, 2)");
|
||||
return await db.WriteAsync(
|
||||
w => new CopiesWorld(
|
||||
Insert(w, "Copied", "m.sha256", "NULL", $"{Spread} % 3 = 0"),
|
||||
Insert(w, "Removed", "m.sha256", "NULL", $"{Spread} % 3 <> 0 AND {Spread} % 50 = 1"),
|
||||
w =>
|
||||
{
|
||||
var whole = Insert(w, "Copied", "m.sha256", "NULL", $"{Spread} % 3 = 0 AND {Spread} % 10 >= 3");
|
||||
var convertedCopies = Insert(w, "Copied", "m.sha256", "NULL", $"{Spread} % 3 = 0 AND {Spread} % 10 < 3", converted);
|
||||
var removed = Insert(w, "Removed", "m.sha256", "NULL", $"{Spread} % 3 <> 0 AND {Spread} % 50 = 1");
|
||||
// The old original of a file replaced in the library («Tieni il più grande», a rebuild).
|
||||
Insert(w, "Superseded", "'e' || substr(m.sha256, 2)", "m.sha256", $"{Spread} % 3 <> 0 AND {Spread} % 100 = 2"),
|
||||
DueFiles(),
|
||||
accountIds[OwnAccount]),
|
||||
var superseded = Insert(w, "Superseded", "'e' || substr(m.sha256, 2)", "m.sha256", $"{Spread} % 3 <> 0 AND {Spread} % 100 = 2");
|
||||
var frames = Insert(w, "Copied", "m.sha256", "NULL", $"m.kind = 'Video' AND {Spread} % 50 = 7", frame)
|
||||
+ Insert(w, "Removed", "m.sha256", "NULL", $"m.kind = 'Video' AND {Spread} % 100 = 9", frame);
|
||||
return new CopiesWorld(whole + convertedCopies, removed, superseded, DueFiles(), accountIds[OwnAccount], convertedCopies, frames);
|
||||
},
|
||||
ct);
|
||||
}
|
||||
|
||||
/// <summary>The form of the copies an insert writes: variant, format and instant (SQL), name suffix, copy SHA (SQL).</summary>
|
||||
private sealed record Form(string Variant, string Format, string FrameAt, string Suffix, string? CopySha)
|
||||
{
|
||||
public static readonly Form Whole = new("Whole", "'Original'", "NULL", ".jpg", null);
|
||||
}
|
||||
|
||||
/// <summary>The due files of the fill, from its rules: every file, but none of account 7 and only the photos of account 4.</summary>
|
||||
private static int DueFiles() => Enumerable.Range(0, Entries).Sum(n => (n % Accounts) switch
|
||||
{
|
||||
@@ -285,6 +308,9 @@ public sealed class LibraryScaleTests
|
||||
Assert.AreEqual(copies.Due - copies.Copied - copies.Removed - copies.Superseded, files[LibraryCopiesFilter.NotCopied]);
|
||||
}
|
||||
|
||||
/// <summary>What the export fill wrote: copies by state, the due files, and the account with its own folder.</summary>
|
||||
private sealed record CopiesWorld(int Copied, int Removed, int Superseded, int Due, long OwnAccountId);
|
||||
/// <summary>
|
||||
/// What the export fill wrote: copies by state (<paramref name="Copied"/> with the converted ones), the due files, the
|
||||
/// account with its own folder, and of tappa E3 the converted copies and the frames (copied and «Tolto»).
|
||||
/// </summary>
|
||||
private sealed record CopiesWorld(int Copied, int Removed, int Superseded, int Due, long OwnAccountId, int Converted, int Frames);
|
||||
}
|
||||
Reference in new issue
Block a user