refactor(config): fold maintenance_revalidate_batch from app_state into sysconfig (E3 S3, B-core-11)
The admin-tunable maintenance re-validation batch lived in its own app_state column with a hand-rolled override-or-default reader in app.state — a fourth config store duplicating the sysconfig SPECS pattern. Move it to a sysconfig key (`maintenance` group, min=100 max=100_000): the reader (sync/maintenance.py) and the Scheduler dashboard (routes/scheduler.py PATCH + GET) now go through sysconfig.get_int / set_value / spec, and app.state loses get/set_maintenance_batch + the MIN/MAX constants + the settings import. Migration 0070 carries any existing override into the system_config store before dropping the app_state column (reversible; restores + copies back on downgrade). Reuses the existing sysconfig.spec() for the dashboard's min/max, so the bounds have one source. Full lane 365 pass (migration drift + reversibility exercised), ruff clean.
This commit is contained in:
@@ -25,11 +25,10 @@ from datetime import timedelta
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app import progress, quota
|
||||
from app import progress, quota, sysconfig
|
||||
from app.config import settings
|
||||
from app.models import Playlist, PlaylistItem, Video
|
||||
from app.notifications import create_notification
|
||||
from app.state import get_maintenance_batch
|
||||
from app.sync.runner import get_service_user
|
||||
from app.sync.videos import apply_video_details, parse_dt
|
||||
from app.utils import now_utc as _now
|
||||
@@ -182,7 +181,7 @@ def _recheck_flagged(db: Session, yt: YouTubeClient) -> dict:
|
||||
def _revalidate_rolling(db: Session, yt: YouTubeClient) -> dict:
|
||||
"""Phase 2: re-check the least-recently-checked currently-available videos and flag any
|
||||
that have become unplayable (hidden immediately; deleted later if they don't recover)."""
|
||||
batch = get_maintenance_batch(db) # admin override, else config default
|
||||
batch = sysconfig.get_int(db, "maintenance_revalidate_batch") # admin override, else config default
|
||||
flagged_new = 0
|
||||
checked = 0
|
||||
now = _now()
|
||||
|
||||
Reference in New Issue
Block a user