- Store subscriber count from YouTube statistics and show it on channel page - Sync 50 videos per channel with playlistItems pagination support - Show per-channel and per-category new-videos counters (2-day window) - Replace hourly videos sync with activity trigger (2h idle) and incremental backfill (hard cap 200 per channel) - Clicking the sidebar new-videos count filters the category feed to recent videos only (new_only) - Update agent-team docs: deploy after green checks
34 lines
997 B
Python
34 lines
997 B
Python
import logging
|
|
|
|
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
|
from app.config import settings
|
|
from app.db import SessionLocal
|
|
from app.services import sync
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _run_subscriptions_sync() -> None:
|
|
db = SessionLocal()
|
|
try:
|
|
sync.sync_subscriptions(db)
|
|
except sync.SyncInProgress:
|
|
logger.info("Scheduled subscriptions sync skipped: already running")
|
|
except Exception:
|
|
logger.exception("Scheduled subscriptions sync failed")
|
|
finally:
|
|
db.close()
|
|
|
|
|
|
def create_scheduler() -> BackgroundScheduler:
|
|
# Videos sync is not scheduled anymore: it runs on user activity via
|
|
# services.sync_trigger.maybe_trigger_videos_sync (see require_session).
|
|
scheduler = BackgroundScheduler(timezone="UTC")
|
|
scheduler.add_job(
|
|
_run_subscriptions_sync,
|
|
"interval",
|
|
hours=settings.subscriptions_sync_interval_hours,
|
|
id="subscriptions_sync",
|
|
)
|
|
return scheduler
|