fix: 事件异常测服会话和卡片不加 [test]
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,7 +78,8 @@ def poll_event_exceptions(
|
|||||||
stamp = now or datetime.now(SHANGHAI)
|
stamp = now or datetime.now(SHANGHAI)
|
||||||
if stamp.tzinfo is None:
|
if stamp.tzinfo is None:
|
||||||
stamp = stamp.replace(tzinfo=SHANGHAI)
|
stamp = stamp.replace(tzinfo=SHANGHAI)
|
||||||
test_prefix = str(getattr(cfg, "ytd_env", "") or "").strip().lower() == "test"
|
# 测服会话/卡片也不加 [test],与销售询价正文一致。
|
||||||
|
test_prefix = False
|
||||||
lookup = timeout_lookup or getattr(book, "get_timeout_by_code", None)
|
lookup = timeout_lookup or getattr(book, "get_timeout_by_code", None)
|
||||||
ready = notify_app_flag(notify_ready)
|
ready = notify_app_flag(notify_ready)
|
||||||
sent = 0
|
sent = 0
|
||||||
|
|||||||
@@ -2646,9 +2646,11 @@ def event_exception_session_text(
|
|||||||
事件异常会话两行话术。
|
事件异常会话两行话术。
|
||||||
|
|
||||||
mention=True 时姓名前加 @,多人空格拼接。小时数用后台规则值。
|
mention=True 时姓名前加 @,多人空格拼接。小时数用后台规则值。
|
||||||
|
测服也不加 [test]:这是销售/航线/产品会话,不是运维告警。
|
||||||
"""
|
"""
|
||||||
from agent.policy.event_exception import format_timeout_hours
|
from agent.policy.event_exception import format_timeout_hours
|
||||||
|
|
||||||
|
_ = test_prefix
|
||||||
no = (work_order_no or "").strip() or "-"
|
no = (work_order_no or "").strip() or "-"
|
||||||
kind = (exception_type or "").strip() or "事件异常"
|
kind = (exception_type or "").strip() or "事件异常"
|
||||||
hour_text = format_timeout_hours(hours)
|
hour_text = format_timeout_hours(hours)
|
||||||
@@ -2661,10 +2663,7 @@ def event_exception_session_text(
|
|||||||
f"关联询价工单 {no}。{tagged}已超过 {hour_text} 工作小时 无响应,"
|
f"关联询价工单 {no}。{tagged}已超过 {hour_text} 工作小时 无响应,"
|
||||||
f"事件异常已记录工单,请及时处理。"
|
f"事件异常已记录工单,请及时处理。"
|
||||||
)
|
)
|
||||||
text = f"{kind}\n{body}"
|
return f"{kind}\n{body}"
|
||||||
if test_prefix and not text.startswith("[test]"):
|
|
||||||
return f"[test] {text}"
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def event_exception_alert_payload(
|
def event_exception_alert_payload(
|
||||||
@@ -2678,13 +2677,13 @@ def event_exception_alert_payload(
|
|||||||
事件异常通知卡:走询价消息服务,不走询价小助手。
|
事件异常通知卡:走询价消息服务,不走询价小助手。
|
||||||
|
|
||||||
对齐现网「询价机器人事件告警」:标题用响应异常,正文用「您已超过」。
|
对齐现网「询价机器人事件告警」:标题用响应异常,正文用「您已超过」。
|
||||||
|
测服标题也不加 [test];test_prefix 仅保留兼容入参。
|
||||||
"""
|
"""
|
||||||
from agent.policy.event_exception import format_timeout_hours
|
from agent.policy.event_exception import format_timeout_hours
|
||||||
|
|
||||||
|
_ = test_prefix
|
||||||
no = (work_order_no or "").strip() or "-"
|
no = (work_order_no or "").strip() or "-"
|
||||||
title = (card_title or "").strip() or "事件响应异常"
|
title = (card_title or "").strip() or "事件响应异常"
|
||||||
if test_prefix and not title.startswith("[test]"):
|
|
||||||
title = f"[test] {title}"
|
|
||||||
hour_text = format_timeout_hours(hours)
|
hour_text = format_timeout_hours(hours)
|
||||||
from agent.config import get_settings
|
from agent.config import get_settings
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ class TestEventExceptionCopy(unittest.TestCase):
|
|||||||
self.assertNotIn("@王五", text)
|
self.assertNotIn("@王五", text)
|
||||||
|
|
||||||
def test_test_prefix(self) -> None:
|
def test_test_prefix(self) -> None:
|
||||||
|
"""测服会话和应用卡片都不加 [test]。"""
|
||||||
text = copy.event_exception_session_text(
|
text = copy.event_exception_session_text(
|
||||||
exception_type="销售响应超时",
|
exception_type="销售响应超时",
|
||||||
work_order_no="WO1",
|
work_order_no="WO1",
|
||||||
@@ -174,7 +175,17 @@ class TestEventExceptionCopy(unittest.TestCase):
|
|||||||
mention=False,
|
mention=False,
|
||||||
test_prefix=True,
|
test_prefix=True,
|
||||||
)
|
)
|
||||||
self.assertTrue(text.startswith("[test] "))
|
self.assertFalse(text.startswith("[test]"))
|
||||||
|
self.assertNotIn("[test]", text)
|
||||||
|
payload = copy.event_exception_alert_payload(
|
||||||
|
card_title="销售响应异常",
|
||||||
|
work_order_no="WO1",
|
||||||
|
hours=1,
|
||||||
|
test_prefix=True,
|
||||||
|
)
|
||||||
|
title = (payload.get("template_card") or {}).get("main_title", {}).get("title") or ""
|
||||||
|
self.assertEqual(title, "销售响应异常")
|
||||||
|
self.assertNotIn("[test]", title)
|
||||||
|
|
||||||
def test_app_card(self) -> None:
|
def test_app_card(self) -> None:
|
||||||
payload = copy.event_exception_alert_payload(
|
payload = copy.event_exception_alert_payload(
|
||||||
|
|||||||
Reference in New Issue
Block a user