D1, seconda parte: «Cosa scaricare prima» anche per account, reel distinti e quota per chi aspetta

L'ordine dei tipi (storie, evidenza, post, reel, taggati) ora vale anche per il singolo account:
nella scheda account → Impostazioni si sceglie «Come le impostazioni generali» o un ordine suo,
con lo stesso elenco da trascinare (o Su/Giù da tastiera) di Limiti e comportamento, ora un
modulo solo (download-order.js). Il motore pesa le visite con l'ordine dell'account, la coda dei
file mette ogni file al posto del suo tipo nell'ordine del suo account, stabile dentro il tipo
(scadenza, scoperta, elemento, posizione).

Perché nessun tipo resti fermo per sempre quando il tetto dei dati finisce prima della coda, un
posto su otto di ogni giro della coda va al file che aspetta da più tempo, di qualunque tipo.

I reel non si inventano (regola 9): un post è reel se viene dalla scheda Reel o se la risposta
ha product_type «clips», valore visto nei campioni ripuliti. Il segno si scrive da solo e non si
toglie mai, così una copia vecchia non sposta di nuovo i file in coda.

Migrazione 0002_ordine_scaricamento (account.download_order, entry.is_reel): prende il primo
numero dopo quelle unite, E1 userà il successivo. Prove su motore (seme fisso), coda, lettori,
ricette e API; dimostrazione con un account che ha l'ordine suo; guida e decisioni aggiornate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-25 15:25:34 +01:00
1 parent d6c0ef851d
commit 0547c747c5
40 files changed
+775 -158

No files matched your search

+31
View File
@@ -1,4 +1,5 @@
using System.Net;
using System.Text.Json;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.Tests.Support;
@@ -65,4 +66,34 @@ public sealed class DashboardApiTests
new { profile = "prudent", pace = "natural", gradualStart = true, activeDays = new[] { 0, 1, 2, 3, 4, 5, 6 }, downloadOrder = DownloadOrder.Default.Kinds.Select(DownloadOrder.NameOf).ToArray() });
Assert.IsNull(await server.Db.Settings.GetAsync(DownloadOrder.SettingKey), "the default order is no stored value");
}
[TestMethod]
public async Task AnAccountFollowsTheGeneralOrderOrHasOneOfItsOwn()
{
await using var server = await Part2.StartAsync();
await server.Db.Settings.SetAsync(DownloadOrder.SettingKey, "post,storie");
var account = await server.Db.Accounts.AddAsync(Make.Account("marta.prova"));
var detail = await server.GetJsonAsync($"/api/accounts/{account.Id}");
Assert.AreEqual(JsonValueKind.Null, detail.GetProperty("settings").GetProperty("downloadOrder").ValueKind, "«Come le impostazioni generali»");
CollectionAssert.AreEqual(new[] { "post", "storie", "evidenza", "reel", "taggati" }, detail.Items("generalDownloadOrder").Select(k => k.GetString()).ToArray());
// «Un ordine suo»: saved with the other settings, completed to the five kinds.
var settings = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(detail.GetProperty("settings").GetRawText())!;
settings["downloadOrder"] = JsonSerializer.SerializeToElement(new[] { "reel", "taggati" });
var (status, saved) = await server.SendJsonAsync(HttpMethod.Put, $"/api/accounts/{account.Id}/settings", settings);
Assert.AreEqual(HttpStatusCode.OK, status);
CollectionAssert.AreEqual(new[] { "reel", "taggati", "storie", "evidenza", "post" }, saved.GetProperty("settings").Items("downloadOrder").Select(k => k.GetString()).ToArray());
Assert.AreEqual("reel,taggati,storie,evidenza,post", (await server.Db.Accounts.GetAsync(account.Id))!.DownloadOrder);
// «Tieni aggiornato» from the table keeps it; back to «Come le impostazioni generali» with null.
(status, _) = await server.SendJsonAsync(HttpMethod.Post, $"/api/accounts/{account.Id}/keep-updated", new { value = false });
Assert.AreEqual(HttpStatusCode.OK, status);
Assert.AreEqual("reel,taggati,storie,evidenza,post", (await server.Db.Accounts.GetAsync(account.Id))!.DownloadOrder);
settings = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>((await server.GetJsonAsync($"/api/accounts/{account.Id}")).GetProperty("settings").GetRawText())!;
settings["downloadOrder"] = JsonSerializer.SerializeToElement<string[]?>(null);
(status, _) = await server.SendJsonAsync(HttpMethod.Put, $"/api/accounts/{account.Id}/settings", settings);
Assert.AreEqual(HttpStatusCode.OK, status);
Assert.IsNull((await server.Db.Accounts.GetAsync(account.Id))!.DownloadOrder);
}
}