mirror of
https://github.com/lintsinghua/DeepAudit.git
synced 2026-08-31 01:40:04 +08:00
修复:平均质量分为0.0
This commit is contained in:
@@ -592,6 +592,7 @@ async def _execute_agent_task(task_id: str):
|
||||
|
||||
# 计算安全评分
|
||||
task.security_score = _calculate_security_score(findings)
|
||||
task.quality_score = _calculate_security_score(findings)
|
||||
# 🔥 注意: progress_percentage 是计算属性,不需要手动设置
|
||||
# 当 status = COMPLETED 时会自动返回 100.0
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ class StatsResponse(BaseModel):
|
||||
completed_tasks: int
|
||||
total_issues: int
|
||||
resolved_issues: int
|
||||
avg_quality_score: float = 0.0
|
||||
|
||||
@router.post("/", response_model=ProjectResponse)
|
||||
async def create_project(
|
||||
@@ -201,6 +202,13 @@ async def get_stats(
|
||||
len([f for f in agent_findings if f.status == "resolved"])
|
||||
)
|
||||
|
||||
# 计算平均质量分(只统计已完成且有质量分的任务)
|
||||
quality_scores = (
|
||||
[t.quality_score for t in tasks if t.status == "completed" and t.quality_score and t.quality_score > 0] +
|
||||
[t.quality_score for t in agent_tasks if t.status == AgentTaskStatus.COMPLETED and t.quality_score and t.quality_score > 0]
|
||||
)
|
||||
avg_quality_score = sum(quality_scores) / len(quality_scores) if quality_scores else 0.0
|
||||
|
||||
return {
|
||||
"total_projects": len(projects),
|
||||
"active_projects": len([p for p in projects if p.is_active]),
|
||||
@@ -208,6 +216,7 @@ async def get_stats(
|
||||
"completed_tasks": completed_tasks,
|
||||
"total_issues": total_issues,
|
||||
"resolved_issues": resolved_issues,
|
||||
"avg_quality_score": avg_quality_score,
|
||||
}
|
||||
|
||||
@router.get("/{id}", response_model=ProjectResponse)
|
||||
|
||||
Generated
+3535
-3535
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user