refactor: one definition of a followed channel and of a choice spelling

The explore purge rebuilt followed_channel's two EXISTS clauses inline, so what is polled and what may be deleted could drift; it now uses the predicate, which moved to sync/explore.py. The env validator and sysconfig each folded a choice value on their own; both call config.canonical_choice. The deep-backfill comment no longer calls recent backfill unconditional.
This commit is contained in:
2026-09-17 03:53:29 +02:00
parent 86bc008a81
commit 4bfba4aa86
5 changed files with 40 additions and 32 deletions
+5 -6
View File
@@ -14,7 +14,7 @@ from dataclasses import dataclass
from sqlalchemy.orm import Session
from app import security
from app.config import Settings, choices_of, settings
from app.config import Settings, canonical_choice, choices_of, settings
from app.models import SystemConfig
log = logging.getLogger("siftlode.config")
@@ -210,11 +210,10 @@ def _default(s: ConfigSpec):
def _choice(s: ConfigSpec, raw: object) -> str:
"""The canonical spelling of `raw` among the key's choices (any letter case), or ValueError."""
folded = str(raw).strip().casefold()
for option in s.choices:
if option.casefold() == folded:
return option
raise ValueError(f"{s.key} must be one of: {', '.join(s.choices)}")
option = canonical_choice(s.choices, raw)
if option is None:
raise ValueError(f"{s.key} must be one of: {', '.join(s.choices)}")
return option
def _coerce(s: ConfigSpec, raw: str):