refactor(сторож): важные уровни находок — один список на письмо и на сохранение меток

Находка зайки: набор ("update", "problem") был продублирован в _notify и в _run_check_body;
правка в одном месте разводила тему письма и состав рассылки. Теперь IMPORTANT_LEVELS.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-18 04:46:30 +10:00
co-authored by Claude Code
parent 21928d4ec7
commit bdc9759423
+7 -2
View File
@@ -25,6 +25,11 @@ import fgis_client as fc
import pravo_client as pc
# Уровни, о которых сообщаем письмом и которые считаем «важными» в отчёте.
# Один список на оба места: иначе тема письма и состав рассылки разъезжаются.
IMPORTANT_LEVELS = ("update", "problem")
def _regions() -> list[int]:
raw = os.environ.get("EXT_REGIONS", "").strip()
if raw.lower() == "all":
@@ -332,7 +337,7 @@ def _notify(findings: list[dict]) -> bool:
import html as _html
def esc(v):
return _html.escape(str(v or ""))
updates = [f for f in findings if f["level"] in ("update", "problem")]
updates = [f for f in findings if f["level"] in IMPORTANT_LEVELS]
rows = "".join(
f"<li><b>[{esc(f['level'])}]</b> {esc(f['source'])}: {esc(f['message'])}"
+ (f"<br><code style='font-size:12px'>{esc(f['action'])}</code>" if f.get("action") else "")
@@ -517,7 +522,7 @@ def _run_check_body(regions: list[int] | None, *, notify: bool) -> dict:
findings += f
_write_report(findings, regions)
updates = [f for f in findings if f["level"] in ("update", "problem")]
updates = [f for f in findings if f["level"] in IMPORTANT_LEVELS]
notify_ok = True
доставлено = not updates
if notify and updates: