D1, correzioni della revisione: conteggi della Libreria più rapidi, frecce che seguono le tessere, Dashboard nei testi
- /api/library/days in «Tutte le foto» faceva due volte il passaggio su tutta la tabella media a ogni aggiornamento del mosaico: il totale dei file è ora la somma dei giorni (CountLibraryFilesAsync tolto). - I totali e i conteggi per giorno di «Foto» e «Video» su tutta la libreria non pagano più un EXISTS per post (1,3-1,6 s): elenco degli elementi con file di quel tipo su un indice di copertura, 86-141 ms su 200.000 elementi; nuove misure con limite 600 ms in LibraryScaleTests. - La quota di chi aspetta non è un minimo per tipo: corretti commento e decisioni, prova con un arretrato più vecchio di un altro tipo. - Visualizzatore in «Tutte le foto»: le frecce saltano i file che non sono tessere (foto sotto «Video» e simili) e l'intestazione non dà il numero di un altro file; la voce già scelta dell'interruttore non ridisegna il mosaico. Prova d'interfaccia nuova (solo CI). - «Ricetta sospesa» dice di riattivarla dalla Dashboard, non da Attività; commenti aggiornati. - Nomi accessibili distinti nella scheda account, variabile in inglese in download-order.js, icona activity tolta perché nessuna pagina la usa. - Schermate 06, 11 e 14 rifatte con /dashboard e nuova 01-libreria-tutte-le-foto, confrontate con i mockup in docs/schermate/differenze.md (con quattro difetti visivi ancora da sistemare). - LEGGIMI del web (mode, cursore, files, moduli riusabili) e guida della Libreria (la scelta del mosaico resta nel browser, a differenza del tema). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
30e159cbd4
commit
58ff4e48b3
44 files changed
+261
-118
No files matched your search
@@ -175,6 +175,8 @@ public sealed class AlertServiceTests
|
||||
Assert.IsTrue(bed.Outcomes.Any(o => o.Alert.Kind == AlertKind.UnknownFormat && o.Kind == AlertOutcomeKind.Repeated));
|
||||
var suspended = texts.Single(t => t.StartsWith("Febe · Ricetta sospesa\n", StringComparison.Ordinal));
|
||||
StringAssert.Contains(suspended, "modalità sonda");
|
||||
StringAssert.Contains(suspended, "si riattiva dalla Dashboard («Riattiva»)", "la pagina si chiama Dashboard (tappa D1)");
|
||||
Assert.IsFalse(suspended.Contains("Attività", StringComparison.Ordinal), suspended);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -97,10 +97,10 @@ public sealed class LibraryFilesTests
|
||||
Assert.HasCount(5, photos.Tiles);
|
||||
Assert.IsTrue(photos.Tiles.All(t => t.CoverKind == MediaKind.Photo));
|
||||
|
||||
Assert.AreEqual(7, await db.Entries.CountLibraryFilesAsync(new LibraryFilter()));
|
||||
Assert.AreEqual(1, await db.Entries.CountLibraryFilesAsync(new LibraryFilter { Kind = LibraryKindFilter.Videos }));
|
||||
Assert.AreEqual(5, await db.Entries.CountLibraryFilesAsync(new LibraryFilter { Kind = LibraryKindFilter.Photos }));
|
||||
Assert.AreEqual(1, await db.Entries.CountLibraryFilesAsync(new LibraryFilter { Kind = LibraryKindFilter.Stories }));
|
||||
Assert.AreEqual(7, await FileTotalAsync(db, new LibraryFilter()));
|
||||
Assert.AreEqual(1, await FileTotalAsync(db, new LibraryFilter { Kind = LibraryKindFilter.Videos }));
|
||||
Assert.AreEqual(5, await FileTotalAsync(db, new LibraryFilter { Kind = LibraryKindFilter.Photos }));
|
||||
Assert.AreEqual(1, await FileTotalAsync(db, new LibraryFilter { Kind = LibraryKindFilter.Stories }));
|
||||
Assert.AreEqual(new LibraryTotals(4, 1), await db.Entries.GetLibraryTotalsAsync(new LibraryFilter()), "the totals stay entries");
|
||||
|
||||
var days = await db.Entries.CountLibraryByDayAsync(new LibraryFilter(), TestZones.Rome, MosaicMode.Files);
|
||||
@@ -113,11 +113,11 @@ public sealed class LibraryFilesTests
|
||||
var other = await db.Accounts.AddAsync(Make.Account("luca.demo"));
|
||||
await db.Entries.AddAsync(Make.Entry(other.Id, "o", new DateTimeOffset(2026, 10, 13, 8, 0, 0, TimeSpan.Zero)), [Make.Stored(Make.Photo(), Make.Sha(41), "o/o.jpg")]);
|
||||
var mine = new LibraryFilter { AccountIds = [accountId] };
|
||||
Assert.AreEqual(7, await db.Entries.CountLibraryFilesAsync(mine));
|
||||
Assert.AreEqual(8, await db.Entries.CountLibraryFilesAsync(new LibraryFilter()));
|
||||
Assert.AreEqual(7, await FileTotalAsync(db, mine));
|
||||
Assert.AreEqual(8, await FileTotalAsync(db, new LibraryFilter()));
|
||||
CollectionAssert.AreEqual(days.ToArray(), (await db.Entries.CountLibraryByDayAsync(mine, TestZones.Rome, MosaicMode.Files)).ToArray());
|
||||
Assert.AreEqual(8, (await db.Entries.CountLibraryByDayAsync(new LibraryFilter(), TestZones.Rome, MosaicMode.Files)).Sum(d => d.Count));
|
||||
Assert.AreEqual(1, await db.Entries.CountLibraryFilesAsync(mine with { Kind = LibraryKindFilter.Videos }));
|
||||
Assert.AreEqual(1, await FileTotalAsync(db, mine with { Kind = LibraryKindFilter.Videos }));
|
||||
|
||||
// A day whose files are all of another kind has no row in «Video».
|
||||
var videoDays = await db.Entries.CountLibraryByDayAsync(new LibraryFilter { Kind = LibraryKindFilter.Videos }, TestZones.Rome, MosaicMode.Files);
|
||||
@@ -129,8 +129,41 @@ public sealed class LibraryFilesTests
|
||||
Assert.AreEqual(new DateOnly(2026, 10, 12), LocalCalendar.Today(fromDay.Tiles.Single().PublishedAt, TestZones.Rome));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task GroupedPhotoAndVideoCountsAgreeWithTheirWindowsWithAndWithoutAccounts()
|
||||
{
|
||||
// The counts of the whole library read one list of the entries with such files, those of an account an EXISTS
|
||||
// per post, the windows always the EXISTS: the same entries every way.
|
||||
using var temp = new TempFolder();
|
||||
await using var db = await TestDatabase.OpenAsync(temp);
|
||||
var (carousel, single, partial, _) = await FillAsync(db);
|
||||
var accountId = (await db.Entries.GetAsync(carousel))!.AccountId;
|
||||
var other = await db.Accounts.AddAsync(Make.Account("luca.demo"));
|
||||
await db.Entries.AddAsync(Make.Entry(other.Id, "v", new DateTimeOffset(2026, 10, 11, 8, 0, 0, TimeSpan.Zero)), [Make.Stored(Make.Video(), Make.Sha(51), "o/v.mp4")]);
|
||||
|
||||
foreach (var (kind, mine, everyone) in new[]
|
||||
{
|
||||
(LibraryKindFilter.Videos, new[] { carousel }, 2),
|
||||
(LibraryKindFilter.Photos, new[] { carousel, partial, single }, 3),
|
||||
})
|
||||
{
|
||||
var all = new LibraryFilter { Kind = kind };
|
||||
var own = all with { AccountIds = [accountId] };
|
||||
Assert.AreEqual(new LibraryTotals(everyone, kind == LibraryKindFilter.Videos ? 2 : 1), await db.Entries.GetLibraryTotalsAsync(all), $"{kind}");
|
||||
Assert.AreEqual(everyone, (await db.Entries.CountLibraryByDayAsync(all, TestZones.Rome)).Sum(d => d.Count));
|
||||
Assert.AreEqual(everyone, (await db.Entries.QueryLibraryAsync(new LibraryQuery { Filter = all })).Tiles.Count);
|
||||
Assert.AreEqual(new LibraryTotals(mine.Length, 1), await db.Entries.GetLibraryTotalsAsync(own), $"{kind} di un account");
|
||||
Assert.AreEqual(mine.Length, (await db.Entries.CountLibraryByDayAsync(own, TestZones.Rome)).Sum(d => d.Count));
|
||||
CollectionAssert.AreEquivalent(mine, (await db.Entries.QueryLibraryAsync(new LibraryQuery { Filter = own })).Tiles.Select(t => t.EntryId).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
private static string Key(LibraryTile tile) => $"{tile.EntryId}.{tile.FilePosition}";
|
||||
|
||||
/// <summary>The files of «Tutte le foto» of a filter: the sum of its days, as /api/library/days gives it.</summary>
|
||||
private static async Task<int> FileTotalAsync(FebeDatabase db, LibraryFilter filter) =>
|
||||
(await db.Entries.CountLibraryByDayAsync(filter, TestZones.Rome, MosaicMode.Files)).Sum(d => d.Count);
|
||||
|
||||
/// <summary>
|
||||
/// A story (13 Oct, 12:00), a carousel of photo, video, photo (13 Oct, 10:00), a post with its second file still to
|
||||
/// download (13 Oct, 9:00) and a single photo (12 Oct, 9:00), all of one account.
|
||||
|
||||
@@ -22,6 +22,9 @@ public sealed class LibraryScaleTests
|
||||
private const double IndexBoundMs = 250;
|
||||
private const double AggregateBoundMs = 1500;
|
||||
|
||||
// «Foto» and «Video» over the whole library: 60-180 ms measured; an EXISTS per post took 1.3-1.6 s and must fail.
|
||||
private const double FilteredAggregateBoundMs = 600;
|
||||
|
||||
public TestContext TestContext { get; set; } = null!;
|
||||
|
||||
[TestMethod]
|
||||
@@ -127,12 +130,19 @@ public sealed class LibraryScaleTests
|
||||
await Measure("tutte le foto: filtro Video", IndexBoundMs, () => db.Entries.QueryLibraryAsync(new LibraryQuery { Limit = 200, Mode = MosaicMode.Files, Filter = new LibraryFilter { Kind = LibraryKindFilter.Videos } }));
|
||||
await Measure("tutte le foto: un account", IndexBoundMs, () => db.Entries.QueryLibraryAsync(new LibraryQuery { Limit = 200, Mode = MosaicMode.Files, Filter = new LibraryFilter { AccountIds = [accountIds[3]] } }));
|
||||
await Measure("tutte le foto: ricerca comune", AggregateBoundMs, () => db.Entries.QueryLibraryAsync(new LibraryQuery { Limit = 200, Mode = MosaicMode.Files, Filter = new LibraryFilter { Search = "caffe" } }));
|
||||
var fileCount = await Measure("tutte le foto: totale dei file", AggregateBoundMs, () => db.Entries.CountLibraryFilesAsync(new LibraryFilter()));
|
||||
Assert.AreEqual(Entries + (Entries / 5), fileCount);
|
||||
// The days give the total of the files too (/api/library/days): one pass over the media table per request.
|
||||
var fileDays = await Measure("tutte le foto: conteggi per giorno", AggregateBoundMs, () => db.Entries.CountLibraryByDayAsync(new LibraryFilter(), TestZones.Rome, MosaicMode.Files));
|
||||
Assert.AreEqual(fileCount, fileDays.Sum(d => d.Count));
|
||||
Assert.AreEqual(Entries + (Entries / 5), fileDays.Sum(d => d.Count));
|
||||
var accountFiles = await Measure("tutte le foto: conteggi di un account", AggregateBoundMs, () => db.Entries.CountLibraryByDayAsync(new LibraryFilter { AccountIds = [accountIds[3]] }, TestZones.Rome, MosaicMode.Files));
|
||||
Assert.AreEqual(await db.Entries.CountLibraryFilesAsync(new LibraryFilter { AccountIds = [accountIds[3]] }, ct), accountFiles.Sum(d => d.Count));
|
||||
Assert.AreEqual(Enumerable.Range(0, Entries).Where(n => n % Accounts == 3).Sum(n => n % 5 == 0 ? 2 : 1), accountFiles.Sum(d => d.Count));
|
||||
// «Foto» and «Video» in the grouped mosaic: the totals and the days of a whole library must not pay an EXISTS
|
||||
// per post (over a second); a list of the entries with such files keeps them near a tenth of a second.
|
||||
var videoTotals = await Measure("totali del filtro Video", FilteredAggregateBoundMs, () => db.Entries.GetLibraryTotalsAsync(new LibraryFilter { Kind = LibraryKindFilter.Videos }));
|
||||
var videoDays = await Measure("conteggi per giorno del filtro Video", FilteredAggregateBoundMs, () => db.Entries.CountLibraryByDayAsync(new LibraryFilter { Kind = LibraryKindFilter.Videos }, TestZones.Rome));
|
||||
Assert.AreEqual(videoTotals.Entries, videoDays.Sum(d => d.Count));
|
||||
Assert.AreEqual(Enumerable.Range(0, Entries).Count(n => n % 10 >= 4 && n % 7 == 0), videoTotals.Entries);
|
||||
var photoTotals = await Measure("totali del filtro Foto", FilteredAggregateBoundMs, () => db.Entries.GetLibraryTotalsAsync(new LibraryFilter { Kind = LibraryKindFilter.Photos }));
|
||||
Assert.AreEqual(Enumerable.Range(0, Entries).Count(n => n % 10 >= 4 && (n % 7 != 0 || n % 5 == 0)), photoTotals.Entries);
|
||||
await Measure("scheda account: Post", IndexBoundMs, () => db.Entries.QueryLibraryAsync(new LibraryQuery { Limit = 200, Filter = new LibraryFilter { AccountIds = [accountIds[3]], Kind = LibraryKindFilter.Posts } }));
|
||||
await Measure("scheda account: Post, tutte le foto", IndexBoundMs, () => db.Entries.QueryLibraryAsync(new LibraryQuery { Limit = 200, Mode = MosaicMode.Files, Filter = new LibraryFilter { AccountIds = [accountIds[3]], Kind = LibraryKindFilter.Posts } }));
|
||||
await Measure("scheda account: conteggi dei Post", AggregateBoundMs, () => db.Entries.CountLibraryByDayAsync(new LibraryFilter { AccountIds = [accountIds[3]], Kind = LibraryKindFilter.Posts }, TestZones.Rome));
|
||||
|
||||
@@ -200,6 +200,40 @@ public sealed class DownloadOrderTests
|
||||
Assert.IsLessThanOrEqualTo(20, rounds, $"i taggati sono arrivati in {rounds} giri");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TheReservedPlaceGoesToTheOldestFileOfTheQueueNotToEachKindInTurn()
|
||||
{
|
||||
// A new account: 40 posts of the backfill found first, then 5 tagged posts, and 7 new posts every round. The
|
||||
// share is not a minimum per kind: while older posts wait, their kind takes the reserved place too, and the
|
||||
// tagged posts come only once that backlog is done. What holds is that no file waits for ever.
|
||||
var waiting = Enumerable.Range(1, 40).Select(i => Pending(i, EntryKind.Post)).ToList();
|
||||
waiting.AddRange(Enumerable.Range(100, 5).Select(i => Pending(i, EntryKind.Tagged)));
|
||||
var next = 1000L;
|
||||
var taggedByRound = new List<int>();
|
||||
while (waiting.Any(p => p.Kind == EntryKind.Tagged) && taggedByRound.Count < 100)
|
||||
{
|
||||
for (var i = 0; i < 7; i++)
|
||||
{
|
||||
waiting.Add(Pending(next++, EntryKind.Post));
|
||||
}
|
||||
|
||||
var ordered = waiting.OrderBy(p => p.Kind == EntryKind.Post ? 0 : 1).ThenBy(p => p.Media.EntryId).ToList();
|
||||
var longest = waiting.OrderBy(p => p.Media.EntryId).ToList();
|
||||
var batch = DownloadQueue.ComposeBatch(ordered, longest, 8, 8);
|
||||
var oldest = longest.First(p => !batch.Take(7).Contains(p));
|
||||
Assert.AreSame(oldest, batch[7], "il posto riservato va al file che aspetta da più tempo, di qualunque tipo");
|
||||
taggedByRound.Add(batch.Count(p => p.Kind == EntryKind.Tagged));
|
||||
foreach (var done in batch)
|
||||
{
|
||||
waiting.Remove(done);
|
||||
}
|
||||
}
|
||||
|
||||
CollectionAssert.AreEqual(new[] { 0, 0, 0, 0, 0 }, taggedByRound.Take(5).ToArray(), "finché i post più vecchi aspettano, i taggati non hanno un posto loro");
|
||||
Assert.AreEqual(5, taggedByRound.Sum(), "poi arrivano tutti");
|
||||
Assert.HasCount(10, taggedByRound, "uno per giro, nel posto riservato");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TheOrderWeighsTheVisitsAfterTheSweepWithoutMakingThemFixed()
|
||||
{
|
||||
|
||||
@@ -66,6 +66,41 @@ public sealed class LibraryModeInterfaceTests
|
||||
Assert.AreEqual("grouped", (await ui.EvalAsync(Mode)).GetString(), "le viste degli account hanno la loro scelta");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task UnderVideoTheArrowsFollowTheTilesAndTheChosenVoiceChangesNothing()
|
||||
{
|
||||
await using var ui = await UiBrowser.StartAsync(1440, 900);
|
||||
using var temp = new TempFolder("modo-video-ui");
|
||||
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
|
||||
|
||||
await ui.OpenAsync(new Uri(demo.Address, "/libreria?tipo=video"));
|
||||
await ui.WaitAsync($"{Switch} !== null && document.querySelector('.mosaico .tess') !== null", "Libreria con «Video»");
|
||||
await ui.EvalAsync($"{Switch}.querySelector('[data-value=files]').click()");
|
||||
|
||||
// A video that is the second file of its post (the first is a photo, no tile under «Video»), not the first tile.
|
||||
const string Second = "[...document.querySelectorAll('.mosaico .tess')].slice(1).find((t) => /^2\\/\\d+$/.test(t.querySelector('.segno span')?.textContent || ''))";
|
||||
await ui.WaitAsync($"({Second}) !== undefined", "un video in seconda posizione " + ui.Report());
|
||||
|
||||
// Clicking the voice already chosen keeps the mosaic, its place and the selection.
|
||||
await ui.EvalAsync("document.querySelector('.mosaico').dataset.prova = 'stesso'");
|
||||
await ui.EvalAsync($"{Switch}.querySelector('[data-value=files]').click()");
|
||||
Assert.AreEqual("stesso", (await ui.EvalAsync("document.querySelector('.mosaico')?.dataset.prova || ''")).GetString(), "«Tutte le foto» di nuovo non ridisegna il mosaico");
|
||||
|
||||
await ui.EvalAsync($"({Second}).click()");
|
||||
await ui.WaitAsync("document.querySelector('.vis .scena video') !== null && /file/.test(document.querySelector('.vis .dove').textContent)", "visualizzatore sul video");
|
||||
const string Index = "Number((document.querySelector('.vis .dove').textContent.match(/file ([\\d.]+)/) || [])[1]?.replace(/\\./g, '') || 0)";
|
||||
var at = (await ui.EvalAsync(Index)).GetInt32();
|
||||
Assert.IsGreaterThan(1, at, ui.Report());
|
||||
|
||||
// Left: the photo before it is not a tile, so the viewer goes to the tile before, a video of another post.
|
||||
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', bubbles: true }))");
|
||||
await ui.WaitAsync($"{Index} === {at - 1}", "la freccia va alla tessera precedente");
|
||||
await ui.WaitAsync("document.querySelector('.vis .scena video') !== null", "di nuovo un video, mai la foto filtrata");
|
||||
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }))");
|
||||
await ui.WaitAsync($"{Index} === {at}", "e torna");
|
||||
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.vis .scena video') !== null")).GetBoolean());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task WithoutTheBrowserStorageTheMosaicIsGrouped()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user