feat(scheduler): admin run-now/run-all triggers + live progress + completion notices
Add per-job "Run now" buttons and a "Start all now" button to the admin Scheduler dashboard (admin-gated endpoints). Triggers run the job in a background thread independent of its interval, refusing a concurrent run (409). While running, the long jobs (maintenance, enrich, backfill, shorts) report live progress through a decoupled contextvar sink, shown as a progress bar on the job row via the existing 4s poll. A manually-triggered run posts a completion notification to the triggering admin's inbox (scheduled runs stay silent to avoid spam); the inbox renders the "scheduler" type trilingually from type+data. While here, give the maintenance job its missing dashboard label/description in all three languages.
This commit is contained in:
parent
3a0789ebe7
commit
ed4194a8d3
15 changed files with 344 additions and 30 deletions
|
|
@ -25,7 +25,7 @@ from datetime import datetime, timedelta, timezone
|
|||
from sqlalchemy import or_, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app import quota
|
||||
from app import progress, quota
|
||||
from app.config import settings
|
||||
from app.models import Playlist, PlaylistItem, Video, VideoState
|
||||
from app.notifications import create_notification
|
||||
|
|
@ -147,6 +147,7 @@ def _recheck_flagged(db: Session, yt: YouTubeClient) -> dict:
|
|||
)
|
||||
if not flagged:
|
||||
return {"checked": 0, "recovered": 0, "deleted": 0, "notified": 0}
|
||||
progress.report(0, len(flagged), "recheck")
|
||||
items = {it["id"]: it for it in yt.get_videos([v.id for v in flagged])}
|
||||
now = _now()
|
||||
recovered = 0
|
||||
|
|
@ -221,6 +222,7 @@ def _revalidate_rolling(db: Session, yt: YouTubeClient) -> dict:
|
|||
flagged_new += 1
|
||||
db.commit()
|
||||
checked += len(page)
|
||||
progress.report(checked, batch, "revalidate")
|
||||
return {"checked": checked, "flagged": flagged_new}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue