feat(m5d): demand-driven deep backfill + per-user ETA
Per-user opt-in to full-history (deep) backfill so a new user's unique channels no longer trigger a big shared-quota burst. - migration 0007: Subscription.deep_requested (default false); seed admins' existing subscriptions to preserve today's global-backfill behaviour - run_deep_backfill is now demand-driven: only channels at least one user has requested are deep-backfilled; recent backfill stays unconditional (cheap) - estimate_deep_backfill ETA helper (quota-bound) surfaced in /api/sync/my-status - POST /api/sync/deep-all to opt all my channels in; PATCH channels accepts deep_requested - UI: per-channel Full history toggle, Backfill everything action, deep progress + ETA in Channels header and Settings - Sync
This commit is contained in:
parent
ba2abf5019
commit
6eb78b9475
9 changed files with 256 additions and 18 deletions
37
backend/alembic/versions/0007_deep_requested.py
Normal file
37
backend/alembic/versions/0007_deep_requested.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"""per-user opt-in to full-history (deep) backfill
|
||||
|
||||
Revision ID: 0007_deep_requested
|
||||
Revises: 0006_app_state
|
||||
Create Date: 2026-06-11
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision: str = "0007_deep_requested"
|
||||
down_revision: Union[str, None] = "0006_app_state"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"subscriptions",
|
||||
sa.Column(
|
||||
"deep_requested",
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default="false",
|
||||
),
|
||||
)
|
||||
# Preserve today's behaviour: admins already had every channel deep-backfilling
|
||||
# globally, so opt their existing subscriptions in. Other users start recent-only.
|
||||
op.execute(
|
||||
"UPDATE subscriptions SET deep_requested = true "
|
||||
"WHERE user_id IN (SELECT id FROM users WHERE role = 'admin')"
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("subscriptions", "deep_requested")
|
||||
Loading…
Add table
Add a link
Reference in a new issue