Fix popular fetch and improve date/view_count coverage

Popular fetch now does a two-phase approach: fast flat-playlist to get
IDs in popularity order, then parallel full metadata fetch (8 workers)
to get real view_count and published_at for each video. Previously
flat-playlist mode returned timestamp/view_count as null.

Enrich task now also backfills published_at and view_count (not just
description). Startup limit 3→50, enrichment sleep 2s→0.5s.

Raise all thread pool sizes to match 8-core machine:
- Discovery search: 5→8 workers
- Graph signal: 4→8 workers
- Popular fetch: 5→8 workers
- Download semaphore default 3→6, cap 10→16

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 22:36:18 +02:00
parent 5b0cf27f07
commit 2f37072187
5 changed files with 82 additions and 56 deletions

View File

@@ -112,7 +112,7 @@ def _search_and_store(
except Exception:
return []
with ThreadPoolExecutor(max_workers=5) as pool:
with ThreadPoolExecutor(max_workers=8) as pool:
futures = {pool.submit(_do_search, q): q for q in queries}
for fut in as_completed(futures):
for video in fut.result():
@@ -620,7 +620,7 @@ def update_graph_signal(db: Session, user_id: int):
return []
featured_map: dict[str, list[str]] = {}
with ThreadPoolExecutor(max_workers=4) as pool:
with ThreadPoolExecutor(max_workers=8) as pool:
futures = {pool.submit(_fetch, row["youtube_channel_id"]): row for row in sample}
for fut in as_completed(futures):
row = futures[fut]