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:
1 parent
d6c0ef851d
commit
0547c747c5
40 files changed
+775
-158
No files matched your search
@@ -0,0 +1,15 @@
|
||||
using Febe.Core.Domain;
|
||||
|
||||
namespace Febe.Core.Storage;
|
||||
|
||||
/// <summary>
|
||||
/// The order of «Cosa scaricare prima» for the queue of the files (spec §6.5, §7.2): the five kinds first to last, in
|
||||
/// general and for the accounts with an order of their own. Built by <c>Febe.Core.Engine.DownloadOrder.LoadQueueOrderAsync</c>.
|
||||
/// </summary>
|
||||
/// <param name="General">The general order.</param>
|
||||
/// <param name="Accounts">The own order of an account, by its local key; the others follow <paramref name="General"/>.</param>
|
||||
public sealed record DownloadQueueOrder(IReadOnlyList<DownloadKind> General, IReadOnlyDictionary<long, IReadOnlyList<DownloadKind>> Accounts)
|
||||
{
|
||||
/// <summary>The order for every account: <paramref name="general"/>, no account with its own.</summary>
|
||||
public static DownloadQueueOrder Everywhere(IReadOnlyList<DownloadKind> general) => new(general, new Dictionary<long, IReadOnlyList<DownloadKind>>());
|
||||
}
|
||||
@@ -19,6 +19,12 @@ public interface IAccountStore
|
||||
/// <summary>All accounts, ordered by user name.</summary>
|
||||
Task<IReadOnlyList<Account>> ListAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// The stored text of «Cosa scaricare prima» of the accounts that have an order of their own (spec §4.4), by local
|
||||
/// key; the accounts that follow the general order are left out. Read by the queue of the files at every batch.
|
||||
/// </summary>
|
||||
Task<IReadOnlyDictionary<long, string>> ListDownloadOrdersAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>All accounts with their counts; «new» counts are entries discovered at or after <paramref name="newSince"/>.</summary>
|
||||
Task<IReadOnlyList<AccountSummary>> ListSummariesAsync(DateTimeOffset newSince, CancellationToken ct = default);
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@ public interface IEntryStore
|
||||
/// <summary>Replaces the mutable fields of an entry (Instagram identifier, code, caption, author, state, dates).</summary>
|
||||
Task UpdateAsync(Entry entry, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Marks a post as a reel (spec §7.2, «Cosa scaricare prima»), writing only that flag; other kinds are left as they are.
|
||||
/// A reel never goes back to a plain post: <see cref="UpdateAsync"/> keeps the flag once set.
|
||||
/// </summary>
|
||||
Task MarkReelAsync(long entryId, CancellationToken ct = default);
|
||||
|
||||
Task SetStateAsync(long entryId, EntryState state, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Recomputes the state of an entry from its files (<see cref="EntryStateRules.FromMedia"/>).</summary>
|
||||
|
||||
@@ -31,11 +31,18 @@ public interface IMediaStore
|
||||
Task<IReadOnlyList<PendingDownload>> ListPendingDownloadsAsync(int limit, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Files waiting to be downloaded in the order of «Cosa scaricare prima» (spec §6.5, §7.2): the files of the entry kind
|
||||
/// that comes first in <paramref name="kindOrder"/>, then the other kinds in that order, and within a kind the ones
|
||||
/// that expire first, then the oldest waiting. A kind left out of the list goes last.
|
||||
/// Files waiting to be downloaded in the order of «Cosa scaricare prima» (spec §6.5, §7.2): for each file the position
|
||||
/// of its kind (a post Febe knows to be a reel counts as a reel) in the order of its account, which is the account's
|
||||
/// own when it has one, else the general one; within a position the ones that expire first, then the oldest
|
||||
/// waiting, then entry and position (stable).
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<PendingDownload>> ListPendingDownloadsAsync(int limit, IReadOnlyList<EntryKind> kindOrder, CancellationToken ct = default);
|
||||
Task<IReadOnlyList<PendingDownload>> ListPendingDownloadsAsync(int limit, DownloadQueueOrder order, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Files waiting to be downloaded, the longest waiting first (discovery, then entry and position), whatever their
|
||||
/// kind: the share of the queue that keeps the later kinds of «Cosa scaricare prima» from waiting for ever.
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<PendingDownload>> ListLongestWaitingDownloadsAsync(int limit, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Files waiting to be downloaded, for one account or overall («lo storico non corre più veloce dei download»).</summary>
|
||||
Task<int> CountPendingDownloadsAsync(long? accountId = null, CancellationToken ct = default);
|
||||
|
||||
Reference in new issue
Block a user