E4: dimostrazione e passi delle schermate che reggono a ogni ora

Quale video sia fermo dipende dall'ora: i passi lo cercano in tutta la libreria e dicono se manca. La dimostrazione
chiude la ricerca prima dell'archivio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 18:57:59 +01:00
1 parent 2c0cfcccf2
commit 18d8b70638
6 files changed
+68 -32

No files matched your search

+6
View File
@@ -3,6 +3,7 @@ using Febe.Core.Engine;
using Febe.Core.Export; using Febe.Core.Export;
using Febe.Core.Import; using Febe.Core.Import;
using Febe.Core.Library; using Febe.Core.Library;
using Febe.Core.Library.StillVideos;
using Febe.Core.Storage; using Febe.Core.Storage;
using Febe.Data; using Febe.Data;
using Febe.Web.Connection; using Febe.Web.Connection;
@@ -137,6 +138,11 @@ public sealed class DemoHost : IAsyncDisposable
try try
{ {
await App.StopAsync().ConfigureAwait(false); await App.StopAsync().ConfigureAwait(false);
// «Cerca i video fermi» at work gives its video up and ends before the database closes, as in Febe itself.
var stills = App.Services.GetRequiredService<StillVideoService>();
stills.Dispose();
await stills.Job.ConfigureAwait(false);
} }
finally finally
{ {
+10 -8
View File
@@ -10,17 +10,19 @@ using Febe.Data;
namespace Febe.Web.Demo; namespace Febe.Web.Demo;
/// <summary> /// <summary>
/// The still videos of the demo (spec §4.10 «Video fermi», tappa E4): two videos (the newest of @marta.demo and the /// The still videos of the demo (spec §4.10 «Video fermi», tappa E4): two videos (the newest of @marta.demo on a picture
/// newest story video of another account, on another picture) become their cover picture alone for two seconds, each in /// no copy uses, and the newest such story video of another account, on another picture: which ones depends on the day and
/// its own file recorded with its own SHA-256 (so «Salva il fotogramma» works both with «Scarica» and «Nella cartella delle copie»), /// the hour, they can be stories or months old) become their cover picture alone for two seconds, each in its own file
/// with a «Fermo» analysis that the real analyser gave on that file. Another video of @marta.demo has an «In movimento» /// recorded with its own SHA-256 (so «Salva il fotogramma» works both with «Scarica» and «Nella cartella delle copie»),
/// analysis (of the demo's moving file), a third «Non analizzabile» because it took too long («Analizza di nuovo»); the /// with a «Fermo» analysis that the real analyser gave on that file. The next two videos of @marta.demo chosen the same way
/// rest is never analysed, so «È un video fermo?» and «Cerca i video fermi» work live. Analyses are only on request in /// have an «In movimento» analysis (of the demo's moving file) and a «Non analizzabile» because it took too long («Analizza
/// Febe: these rows stand for requests made in the days before. Every scene of the demo sees them. /// di nuovo»); other videos on the same pictures have the same outcome. The rest is never analysed, so «È un video fermo?»
/// and «Cerca i video fermi» work live. Analyses are only on request in Febe: these rows stand for requests made in the days
/// before. Every scene of the demo sees them.
/// </summary> /// </summary>
public static class DemoStillVideos public static class DemoStillVideos
{ {
/// <summary>The account whose newest video is still (and whose next two are «In movimento» and «Non analizzabile»).</summary> /// <summary>The account whose newest video on a picture without copies is still (the next two are «In movimento» and «Non analizzabile»).</summary>
public const string StillAccount = DemoExport.CopiedAccount; public const string StillAccount = DemoExport.CopiedAccount;
/// <summary>The file name of the still video of position <paramref name="n"/> (1 or 2).</summary> /// <summary>The file name of the still video of position <paramref name="n"/> (1 or 2).</summary>
+9 -8
View File
@@ -98,18 +98,19 @@ public sealed class DemoStillVideoTests
async Task WaitAsync(string path, string what) async Task WaitAsync(string path, string what)
{ {
for (var i = 0; i < 600; i++) // Bounded by the test's own timeout, whatever else the machine does.
while ((await OkAsync(HttpMethod.Get, path)).Bool("running"))
{ {
if (!(await OkAsync(HttpMethod.Get, path)).Bool("running")) try
{ {
return;
}
await Task.Delay(100, ct); await Task.Delay(100, ct);
} }
catch (OperationCanceledException)
{
Assert.Fail(what); Assert.Fail(what);
} }
}
}
// Two still files, each recorded with its own SHA-256 and served for its video. // Two still files, each recorded with its own SHA-256 and served for its video.
Assert.HasCount(2, demo.World.StillVideoFiles); Assert.HasCount(2, demo.World.StillVideoFiles);
@@ -190,10 +191,10 @@ public sealed class DemoStillVideoTests
var again = await OkAsync(HttpMethod.Post, $"/api/media/{mediaId}/still"); var again = await OkAsync(HttpMethod.Post, $"/api/media/{mediaId}/still");
Assert.AreEqual(("still", stillMedia.GetProperty("still").Long("frameAtMs")), (again.Str("outcome"), again.Long("frameAtMs")), "the still video again"); Assert.AreEqual(("still", stillMedia.GetProperty("still").Long("frameAtMs")), (again.Str("outcome"), again.Long("frameAtMs")), "the still video again");
// «Cerca i video fermi» over the account: the already analysed are skipped, the rest is «In movimento».
var selection = new { accountId = marta }; var selection = new { accountId = marta };
var search = await OkAsync(HttpMethod.Post, "/api/still-videos/plan", selection); var search = await OkAsync(HttpMethod.Post, "/api/still-videos/plan", selection);
Assert.IsGreaterThanOrEqualTo(4, search.Int("alreadyAnalysed"), search.ToString()); Assert.IsGreaterThanOrEqualTo(3, search.Int("alreadyAnalysed"), search.ToString());
Assert.IsGreaterThan(0, search.Int("toAnalyse"), search.ToString()); Assert.IsGreaterThan(0, search.Int("toAnalyse"), search.ToString());
Assert.IsNull(search.GetProperty("waiting").GetString(), "the demo is never in a session for the job"); Assert.IsNull(search.GetProperty("waiting").GetString(), "the demo is never in a session for the job");
await OkAsync(HttpMethod.Post, "/api/still-videos/start", selection); await OkAsync(HttpMethod.Post, "/api/still-videos/start", selection);
@@ -5,20 +5,30 @@ const until = async (test, tries = 100) => { for (let i = 0; i < tries && !test(
const json = (path) => fetch(path, { headers: { Accept: 'application/json' } }).then((r) => r.json()); const json = (path) => fetch(path, { headers: { Accept: 'application/json' } }).then((r) => r.json());
const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo'); const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo');
const tiles = (await json(`/api/library?accounts=${marta.id}&kind=videos&limit=100`)).tiles; // Which video it is depends on the day and the hour of the demo: every file of the account, also inside a series.
let found = null; const videos = [];
for (const x of tiles) { for (let cursor = null, i = 0; i < 40; i++) {
const entry = await json(`/api/entries/${x.id}`); const page = await json(`/api/library?accounts=${marta.id}&mode=files&limit=600${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
if (entry.media.length === 1 && entry.media[0].available && !entry.media[0].still && entry.media[0].framesAvailable) { videos.push(...page.tiles.filter((x) => x.cover && x.cover.kind === 'video'));
found = entry; if (!(cursor = page.older)) break;
break;
}
} }
const wanted = (m) => m.kind === 'video' && m.available && m.framesAvailable && !m.still;
let found = null;
for (let i = 0; i < videos.length && !found; i += 16) {
const entries = await Promise.all(videos.slice(i, i + 16).map((x) => json(`/api/entries/${x.id}`)));
found = entries.find((e) => e.media.some(wanted));
}
if (!found) throw new Error('La dimostrazione non ha un video di @marta.demo mai analizzato.');
const { navigate } = await import('/js/core/shell.js'); const { navigate } = await import('/js/core/shell.js');
await navigate(`/libreria?account=${marta.id}&dal=${found.publishedDay}&al=${found.publishedDay}`); await navigate(`/libreria?account=${marta.id}&dal=${found.publishedDay}&al=${found.publishedDay}`);
const tile = () => document.querySelector(`.mosaico .tess[data-entry="${found.id}"]`); const tile = () => document.querySelector(`.mosaico .tess[data-entry="${found.id}"]`);
await until(tile); await until(tile);
tile().click(); tile().click();
await until(() => document.querySelector('.vis .riga-file, .vis video, .vis img'));
for (let i = found.media.findIndex(wanted); i > 0; i--) {
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight' }));
await sleep(300);
}
await until(() => document.querySelector('.vis .azione-video-fermo') && document.querySelector('.vis video')?.readyState >= 2); await until(() => document.querySelector('.vis .azione-video-fermo') && document.querySelector('.vis video')?.readyState >= 2);
const video = document.querySelector('.vis video'); const video = document.querySelector('.vis video');
video.pause(); video.pause();
@@ -5,20 +5,30 @@ const until = async (test, tries = 100) => { for (let i = 0; i < tries && !test(
const json = (path) => fetch(path, { headers: { Accept: 'application/json' } }).then((r) => r.json()); const json = (path) => fetch(path, { headers: { Accept: 'application/json' } }).then((r) => r.json());
const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo'); const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo');
const tiles = (await json(`/api/library?accounts=${marta.id}&kind=videos&limit=100`)).tiles; // Which video it is depends on the day and the hour of the demo: every file of the account, also inside a series.
let found = null; const videos = [];
for (const x of tiles) { for (let cursor = null, i = 0; i < 40; i++) {
const entry = await json(`/api/entries/${x.id}`); const page = await json(`/api/library?accounts=${marta.id}&mode=files&limit=600${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
if (entry.media[0].still?.outcome === 'notAnalyzable') { videos.push(...page.tiles.filter((x) => x.cover && x.cover.kind === 'video'));
found = entry; if (!(cursor = page.older)) break;
break;
}
} }
const wanted = (m) => m.still?.outcome === 'notAnalyzable';
let found = null;
for (let i = 0; i < videos.length && !found; i += 16) {
const entries = await Promise.all(videos.slice(i, i + 16).map((x) => json(`/api/entries/${x.id}`)));
found = entries.find((e) => e.media.some(wanted));
}
if (!found) throw new Error('La dimostrazione non ha un video di @marta.demo «Non analizzabile».');
const { navigate } = await import('/js/core/shell.js'); const { navigate } = await import('/js/core/shell.js');
await navigate(`/libreria?account=${marta.id}&dal=${found.publishedDay}&al=${found.publishedDay}`); await navigate(`/libreria?account=${marta.id}&dal=${found.publishedDay}&al=${found.publishedDay}`);
const tile = () => document.querySelector(`.mosaico .tess[data-entry="${found.id}"]`); const tile = () => document.querySelector(`.mosaico .tess[data-entry="${found.id}"]`);
await until(tile); await until(tile);
tile().click(); tile().click();
await until(() => document.querySelector('.vis .riga-file, .vis video, .vis img'));
for (let i = found.media.findIndex(wanted); i > 0; i--) {
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight' }));
await sleep(300);
}
await until(() => document.querySelector('.vis .analizza-di-nuovo') && document.querySelector('.vis video')?.readyState >= 2); await until(() => document.querySelector('.vis .analizza-di-nuovo') && document.querySelector('.vis video')?.readyState >= 2);
const video = document.querySelector('.vis video'); const video = document.querySelector('.vis video');
video.pause(); video.pause();
@@ -7,9 +7,16 @@ const json = (path) => fetch(path, { headers: { Accept: 'application/json' } }).
const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo'); const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo');
const still = (await json(`/api/library?kind=stillvideos&accounts=${marta.id}&limit=1`)).tiles[0]; const still = (await json(`/api/library?kind=stillvideos&accounts=${marta.id}&limit=1`)).tiles[0];
if (!still) throw new Error('La dimostrazione non ha un video fermo di @marta.demo.');
const tile = () => document.querySelector(`.mosaico .tess[data-entry="${still.id}"]`); const tile = () => document.querySelector(`.mosaico .tess[data-entry="${still.id}"]`);
await until(tile); await until(tile);
tile().click(); tile().click();
const entry = await json(`/api/entries/${still.id}`);
await until(() => document.querySelector('.vis video, .vis img'));
for (let i = entry.media.findIndex((m) => m.still?.outcome === 'still'); i > 0; i--) {
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight' }));
await sleep(300);
}
await until(() => document.querySelector('.vis .azione-salva-fotogramma') && document.querySelector('.vis video')?.readyState >= 2); await until(() => document.querySelector('.vis .azione-salva-fotogramma') && document.querySelector('.vis video')?.readyState >= 2);
const video = document.querySelector('.vis video'); const video = document.querySelector('.vis video');
video.pause(); video.pause();