feat(channels): surface full-history pull + honest stored/total count on the channel page (S3)

The catalog only stores the recent-backfill/RSS subset of a channel's uploads (video_count is
YouTube's raw total), so a subscribed channel looked like it was "missing" videos. Now the channel
page header shows "{stored} / {total} videos" when there's a gap, and a "Full history" action queues
the deep backfill (the same deep_requested trigger the channel manager uses) — showing a loading
state until done. Backend: channel_detail now returns deep_requested/backfill_done.
This commit is contained in:
2026-07-28 02:22:36 +02:00
parent ae14aa1c6a
commit eb922cb589
5 changed files with 80 additions and 8 deletions
+21 -5
View File
@@ -223,7 +223,13 @@ def _channel_summary(ch: Channel) -> dict:
def _channel_detail_dict(
channel: Channel, *, subscribed: bool, explored: bool, blocked: bool, stored: int
channel: Channel,
*,
subscribed: bool,
explored: bool,
blocked: bool,
stored: int,
deep_requested: bool,
) -> dict:
return {
"id": channel.id,
@@ -245,6 +251,10 @@ def _channel_detail_dict(
"explored": explored,
"blocked": blocked,
"stored_videos": stored,
# Deep-backfill state, so the channel page can offer "get full history" when the catalog
# holds only the recent-backfill/RSS subset (video_count is YouTube's raw total).
"deep_requested": deep_requested,
"backfill_done": channel.backfill_done,
"from_explore": channel.from_explore,
"details_synced": channel.details_synced_at is not None,
}
@@ -274,11 +284,12 @@ def channel_detail(
except YouTubeError as exc:
log.warning("channel detail enrich failed (%s): %s", channel_id, exc)
db.rollback()
subscribed = db.execute(
select(Subscription.id).where(
sub = db.execute(
select(Subscription).where(
Subscription.user_id == user.id, Subscription.channel_id == channel_id
)
).first() is not None
).scalar_one_or_none()
subscribed = sub is not None
explored = db.execute(
select(ExploredChannel.id).where(
ExploredChannel.user_id == user.id, ExploredChannel.channel_id == channel_id
@@ -287,7 +298,12 @@ def channel_detail(
blocked = _is_blocked(db, user, channel_id)
stored = db.scalar(select(func.count(Video.id)).where(Video.channel_id == channel_id)) or 0
return _channel_detail_dict(
channel, subscribed=subscribed, explored=explored, blocked=blocked, stored=int(stored)
channel,
subscribed=subscribed,
explored=explored,
blocked=blocked,
stored=int(stored),
deep_requested=bool(sub.deep_requested) if sub else False,
)