feat: 增强处理历史资料规模与会话状态展示

This commit is contained in:
2026-06-04 01:54:11 +08:00
parent 96f710ea13
commit d2a4907561
3 changed files with 71 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
from agent_core.results import AgentResult
from apps.chat.models import Conversation
from apps.documents.models import SubmissionBatch
from .models import AgentAuditLog, NotificationRecord
@@ -106,13 +108,32 @@ def build_history_rows(logs) -> list[dict]:
(item.batch_id, item.conversation_id): item
for item in NotificationRecord.objects.order_by("-created_at")
}
batch_map = {
item.batch_id: item
for item in SubmissionBatch.objects.filter(
batch_id__in=[log.batch_id for log in logs if log.batch_id]
)
}
conversation_map = {
item.conversation_id: item
for item in Conversation.objects.filter(
conversation_id__in=[log.conversation_id for log in logs if log.conversation_id]
)
}
rows = []
for log in logs:
notification = notification_map.get((log.batch_id, log.conversation_id))
batch = batch_map.get(log.batch_id)
conversation = conversation_map.get(log.conversation_id)
structured_output = log.structured_output or {}
rows.append(
{
"log": log,
"batch": batch,
"conversation": conversation,
"batch_scale": f"{batch.file_count} 份 / {batch.page_count}" if batch else "-",
"batch_status": batch.get_import_status_display_text() if batch else "-",
"conversation_status": conversation.task_status if conversation else "-",
"risk_status": structured_output.get("highest_risk_level")
or structured_output.get("risk_level")
or "-",