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
@@ -12,9 +12,9 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
+ "a.unreachable_reason, a.keep_updated, a.frequency, a.custom_post_interval_min, a.custom_story_interval_min, a.content_types, "
|
||||
+ "a.history_depth, a.history_last_posts, a.history_from, a.backfill_posts_per_day, a.max_video_bytes, a.story_videos, a.folder, "
|
||||
+ "a.backfill_cursor, a.backfill_completed_at, a.post_count, a.last_profile_check_at, a.next_profile_check_at, "
|
||||
+ "a.last_stories_check_at, a.next_stories_check_at, a.notices, a.previous_username, a.renamed_at, a.format_unrecognized_at, a.added_at";
|
||||
+ "a.last_stories_check_at, a.next_stories_check_at, a.notices, a.previous_username, a.renamed_at, a.format_unrecognized_at, a.added_at, a.download_order";
|
||||
|
||||
internal const int ColumnCount = 34;
|
||||
internal const int ColumnCount = 35;
|
||||
|
||||
private static readonly string Visible = string.Join(", ", EntryStateRules.Visible.Select(s => $"'{s}'"));
|
||||
|
||||
@@ -57,6 +57,7 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
RenamedAt = r.GetTimeOrNull(o + 31),
|
||||
FormatUnrecognizedAt = r.GetTimeOrNull(o + 32),
|
||||
AddedAt = r.GetTime(o + 33),
|
||||
DownloadOrder = r.GetTextOrNull(o + 34),
|
||||
};
|
||||
|
||||
private static void Bind(SqliteCommand c, Account a)
|
||||
@@ -93,13 +94,16 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
.With("@previous_username", Sql.Text(a.PreviousUsername))
|
||||
.With("@renamed_at", Sql.Time(a.RenamedAt))
|
||||
.With("@format_unrecognized_at", Sql.Time(a.FormatUnrecognizedAt))
|
||||
.With("@added_at", Sql.Time(a.AddedAt));
|
||||
.With("@added_at", Sql.Time(a.AddedAt))
|
||||
.With("@download_order", Sql.Text(NormalizeOrder(a.DownloadOrder)));
|
||||
}
|
||||
|
||||
private static string? Normalize(string? instagramId) => string.IsNullOrWhiteSpace(instagramId) ? null : instagramId.Trim();
|
||||
|
||||
private static string NormalizeUsername(string username) => username.Trim().TrimStart('@');
|
||||
|
||||
private static string? NormalizeOrder(string? order) => string.IsNullOrWhiteSpace(order) ? null : order.Trim();
|
||||
|
||||
private static void Validate(Account account)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(account);
|
||||
@@ -153,6 +157,21 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
},
|
||||
ct);
|
||||
|
||||
public Task<IReadOnlyDictionary<long, string>> ListDownloadOrdersAsync(CancellationToken ct = default) =>
|
||||
db.ReadAsync<IReadOnlyDictionary<long, string>>(
|
||||
c =>
|
||||
{
|
||||
using var r = c.Command("SELECT id, download_order FROM account WHERE download_order IS NOT NULL").ExecuteReader();
|
||||
var orders = new Dictionary<long, string>();
|
||||
while (r.Read())
|
||||
{
|
||||
orders[r.GetInt64(0)] = r.GetString(1);
|
||||
}
|
||||
|
||||
return orders;
|
||||
},
|
||||
ct);
|
||||
|
||||
public Task<IReadOnlyList<AccountSummary>> ListSummariesAsync(DateTimeOffset newSince, CancellationToken ct = default) =>
|
||||
db.ReadAsync<IReadOnlyList<AccountSummary>>(
|
||||
c =>
|
||||
@@ -261,12 +280,12 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
unreachable_reason, keep_updated, frequency, custom_post_interval_min, custom_story_interval_min, content_types,
|
||||
history_depth, history_last_posts, history_from, backfill_posts_per_day, max_video_bytes, story_videos, folder,
|
||||
backfill_cursor, backfill_completed_at, post_count, last_profile_check_at, next_profile_check_at,
|
||||
last_stories_check_at, next_stories_check_at, notices, previous_username, renamed_at, format_unrecognized_at, added_at)
|
||||
last_stories_check_at, next_stories_check_at, notices, previous_username, renamed_at, format_unrecognized_at, added_at, download_order)
|
||||
VALUES (@instagram_id, @username, @display_name, @is_private, @is_followed, @is_mine, @state, @state_changed_at,
|
||||
@unreachable_reason, @keep_updated, @frequency, @custom_post_interval_min, @custom_story_interval_min, @content_types,
|
||||
@history_depth, @history_last_posts, @history_from, @backfill_posts_per_day, @max_video_bytes, @story_videos, @folder,
|
||||
@backfill_cursor, @backfill_completed_at, @post_count, @last_profile_check_at, @next_profile_check_at,
|
||||
@last_stories_check_at, @next_stories_check_at, @notices, @previous_username, @renamed_at, @format_unrecognized_at, @added_at)
|
||||
@last_stories_check_at, @next_stories_check_at, @notices, @previous_username, @renamed_at, @format_unrecognized_at, @added_at, @download_order)
|
||||
""");
|
||||
Bind(c, account);
|
||||
try
|
||||
@@ -305,7 +324,7 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
last_profile_check_at = @last_profile_check_at, next_profile_check_at = @next_profile_check_at,
|
||||
last_stories_check_at = @last_stories_check_at, next_stories_check_at = @next_stories_check_at, notices = @notices,
|
||||
previous_username = @previous_username, renamed_at = @renamed_at, format_unrecognized_at = @format_unrecognized_at,
|
||||
added_at = @added_at
|
||||
added_at = @added_at, download_order = @download_order
|
||||
WHERE id = @id
|
||||
""");
|
||||
Bind(c, account);
|
||||
|
||||
Reference in new issue
Block a user