feat(lean-training): 推送游标继承与跨任务去重防重复推送、fix(lean-training): 企微卡片跳转 Agent 按环境动态解析
This commit is contained in:
1 parent
f3cd5e7ae7
commit
17f6fae876
4 files changed
+46
-10
No files matched your search
@@ -19,6 +19,7 @@ from sqlalchemy import func, or_, select
|
||||
from app.core.errors import NotFoundError, ValidationError
|
||||
from app.extensions import db
|
||||
from app.models import (
|
||||
Agent,
|
||||
LeanTrainingCompletion,
|
||||
LeanTrainingWeeklyTask,
|
||||
TrainingConfig,
|
||||
@@ -30,6 +31,36 @@ from app.services.schedule.timezone_util import resolve_schedule_tzinfo, to_utc_
|
||||
|
||||
LEAN_TRAINING_TYPE = "lean_management"
|
||||
MIN_SUMMARY_LENGTH = 50
|
||||
# 精益提醒/推送企微卡片跳转 Agent 的历史默认值;仅当动态解析失败(系统内无培训 Agent)时兜底
|
||||
LEGACY_LEAN_JUMP_AGENT_ID = 27
|
||||
|
||||
|
||||
def resolve_lean_training_jump_agent_id() -> int:
|
||||
"""
|
||||
解析精益提醒/推送企微卡片落地聊天页的「员工培训」Agent ID。
|
||||
|
||||
用途:卡片须跳 /chat/<培训agent>?training_type=lean_management,由前端 TrainingWorkspacePanel
|
||||
自动展开精益页签;前端仅在目标 Agent 是培训 Agent 时才消费深链参数,
|
||||
因此 Agent ID 指错环境会导致卡片落地后无法定位精益模块。
|
||||
核心逻辑:各环境培训 Agent ID 不同,禁止依赖固定值——优先取 WECOM_LEAN_TRAINING_JUMP_AGENT_ID
|
||||
显式配置覆盖,否则在启用 Agent 中按 handler_config.content_profile='training' 动态解析;
|
||||
均不可用时回退历史默认 27 保持兼容。
|
||||
Returns:
|
||||
培训 Agent ID。
|
||||
"""
|
||||
from flask import current_app
|
||||
|
||||
override = int(current_app.config.get("WECOM_LEAN_TRAINING_JUMP_AGENT_ID") or 0)
|
||||
if override > 0:
|
||||
return override
|
||||
agents = db.session.execute(
|
||||
select(Agent).where(Agent.is_active.is_(True)).order_by(Agent.sort_order, Agent.id)
|
||||
).scalars().all()
|
||||
for agent in agents:
|
||||
handler_config = agent.handler_config if isinstance(agent.handler_config, dict) else {}
|
||||
if str(handler_config.get("content_profile") or "").strip() == "training":
|
||||
return int(agent.id)
|
||||
return LEGACY_LEAN_JUMP_AGENT_ID
|
||||
|
||||
|
||||
def _format_dashboard_datetime(value: str | None) -> str:
|
||||
|
||||
Reference in new issue
Block a user