fix(status): ignore promotion edit warnings

This commit is contained in:
chengma
2026-07-20 10:52:32 +08:00
parent b3d9857b3e
commit 9c4224286a
10 changed files with 253 additions and 14 deletions
+28 -4
View File
@@ -56,6 +56,10 @@ COLLECT_SCOPE_ALL = SCOPE_ALL
_WHITESPACE_RE = re.compile(r"\s+")
_NOTE_LIMIT = 2000
_PROMOTION_EDIT_RESTRICTION_MARKERS = (
("促銷", "無法進行編輯"),
("促销", "无法进行编辑"),
)
def normalize_status(value) -> str:
@@ -97,6 +101,22 @@ def normalize_text(value) -> str:
return _WHITESPACE_RE.sub(" ", str(value or "").strip())
def is_promotion_edit_restriction_alert(title, description="") -> bool:
"""Return whether an alert only describes a promotion editing limitation."""
text = normalize_text(f"{title or ''} {description or ''}")
return any(
promotion_marker in text and edit_marker in text
for promotion_marker, edit_marker in _PROMOTION_EDIT_RESTRICTION_MARKERS
)
def is_promotion_edit_restriction_note(note) -> bool:
"""Recognize the persisted summary generated from a known benign alert."""
return is_promotion_edit_restriction_alert(note)
def classify_alerts(alerts) -> dict:
"""Classify normalized EDS warning-alert data without retaining page HTML."""
@@ -105,8 +125,8 @@ def classify_alerts(alerts) -> dict:
if not alerts:
return _snapshot(STATUS_NORMAL, "")
first_note = ""
valid_alert_seen = False
unknown_alert_note = ""
for alert in alerts:
if not isinstance(alert, dict):
continue
@@ -114,16 +134,20 @@ def classify_alerts(alerts) -> dict:
title = normalize_text(alert.get("title"))
description = normalize_text(alert.get("description"))
note = _alert_note(title, description)
if not first_note:
first_note = note
if title in {"審核中", "审核中"}:
return _snapshot(STATUS_REVIEWING, note)
if "您的商品未上架" in title:
return _snapshot(STATUS_UNLISTED, note)
if is_promotion_edit_restriction_alert(title, description):
continue
if not unknown_alert_note:
unknown_alert_note = note
if not valid_alert_seen:
return _snapshot(STATUS_UNKNOWN, "")
return _snapshot(STATUS_UNKNOWN, first_note)
if not unknown_alert_note:
return _snapshot(STATUS_NORMAL, "")
return _snapshot(STATUS_UNKNOWN, unknown_alert_note)
def partition_tasks(tasks) -> dict: