feat: 增强处理历史风险与通知状态展示
This commit is contained in:
@@ -94,3 +94,29 @@ def create_notification_record(
|
||||
web_detail_url=web_detail_url,
|
||||
receipt=receipt,
|
||||
)
|
||||
|
||||
|
||||
def build_history_rows(logs) -> list[dict]:
|
||||
"""
|
||||
为处理历史列表补齐风险状态和通知状态。
|
||||
|
||||
View 只负责收集筛选条件,列表展示所需的聚合字段统一在服务层完成。
|
||||
"""
|
||||
notification_map = {
|
||||
(item.batch_id, item.conversation_id): item
|
||||
for item in NotificationRecord.objects.order_by("-created_at")
|
||||
}
|
||||
rows = []
|
||||
for log in logs:
|
||||
notification = notification_map.get((log.batch_id, log.conversation_id))
|
||||
structured_output = log.structured_output or {}
|
||||
rows.append(
|
||||
{
|
||||
"log": log,
|
||||
"risk_status": structured_output.get("highest_risk_level")
|
||||
or structured_output.get("risk_level")
|
||||
or "-",
|
||||
"notify_status": notification.message_status if notification else "-",
|
||||
}
|
||||
)
|
||||
return rows
|
||||
|
||||
Reference in New Issue
Block a user