feat(scheduler): admin-tunable maintenance re-validation batch size
Expose the maintenance job's rolling re-validation batch (videos re-checked per run) as an admin control on the Scheduler dashboard, stored in app_state (migration 0018; NULL = the env/config default). The job reads the effective value each run via a state helper, clamped to a sane range. Trilingual.
This commit is contained in:
@@ -71,6 +71,29 @@ def run_all_now(user: User = Depends(admin_user)) -> dict:
|
||||
return {"started": trigger_all(actor_id=user.id)}
|
||||
|
||||
|
||||
@router.patch("/maintenance")
|
||||
def set_maintenance_settings(
|
||||
payload: dict,
|
||||
_: User = Depends(admin_user),
|
||||
db: Session = Depends(get_db),
|
||||
) -> dict:
|
||||
"""Admin-tune the maintenance job's rolling re-validation batch (videos re-checked per
|
||||
run). Persisted to app_state; the job reads it each run."""
|
||||
try:
|
||||
value = int(payload.get("revalidate_batch"))
|
||||
except (TypeError, ValueError):
|
||||
raise HTTPException(status_code=400, detail="revalidate_batch must be a number")
|
||||
if not (state.MAINTENANCE_BATCH_MIN <= value <= state.MAINTENANCE_BATCH_MAX):
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=(
|
||||
f"revalidate_batch must be between {state.MAINTENANCE_BATCH_MIN} and "
|
||||
f"{state.MAINTENANCE_BATCH_MAX}"
|
||||
),
|
||||
)
|
||||
return {"revalidate_batch": state.set_maintenance_batch(db, value)}
|
||||
|
||||
|
||||
@router.get("")
|
||||
def get_scheduler(
|
||||
_: User = Depends(admin_user), db: Session = Depends(get_db)
|
||||
@@ -138,4 +161,10 @@ def get_scheduler(
|
||||
"paused": state.is_sync_paused(db),
|
||||
"queue": queue,
|
||||
"quota": quota_info,
|
||||
"maintenance": {
|
||||
"revalidate_batch": state.get_maintenance_batch(db),
|
||||
"revalidate_batch_default": settings.maintenance_revalidate_batch,
|
||||
"min": state.MAINTENANCE_BATCH_MIN,
|
||||
"max": state.MAINTENANCE_BATCH_MAX,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user