fix: remove sha256 duplicate check so re-upload always creates new version in group
This commit is contained in:
@@ -21,16 +21,33 @@ class ResultAdapter:
|
||||
- 前端 VO 字典
|
||||
"""
|
||||
|
||||
def AdaptRunSummary(self, EngineResult: AuditResult) -> dict[str, Any]:
|
||||
"""从 AuditResult.summary 提取 run 汇总字段。"""
|
||||
def AdaptRunSummary(
|
||||
self,
|
||||
EngineResult: AuditResult,
|
||||
Structure: list[dict[str, Any]] | None = None,
|
||||
Outline: list[dict[str, Any]] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""从 AuditResult.summary 提取 run 汇总字段。
|
||||
|
||||
同时接受已适配的 structure / outline 列表,一并序列化进
|
||||
resultSummaryJson,供前端 structure-panel / outline-panel 读取。
|
||||
"""
|
||||
import json
|
||||
|
||||
s = EngineResult.summary
|
||||
aux: dict[str, Any] = {}
|
||||
if Structure is not None:
|
||||
aux["structure"] = Structure
|
||||
if Outline is not None:
|
||||
aux["outline"] = Outline
|
||||
|
||||
return {
|
||||
"totalScore": s.score,
|
||||
"passedCount": s.passed_count,
|
||||
"failedCount": s.failed_count,
|
||||
"skippedCount": s.skipped_count,
|
||||
"resultStatus": "pass" if s.failed_count == 0 else "fail" if s.passed_count == 0 else "partial",
|
||||
"resultSummaryJson": None, # 可为后续扩展预留
|
||||
"resultSummaryJson": json.dumps(aux, ensure_ascii=False) if aux else None,
|
||||
}
|
||||
|
||||
def AdaptRuleResults(self, EngineResult: AuditResult) -> list[dict[str, Any]]:
|
||||
|
||||
@@ -74,13 +74,20 @@ class GovdocRunner:
|
||||
)
|
||||
|
||||
# 4. 适配引擎结果
|
||||
runSummary = self.ResultAdapter.AdaptRunSummary(engineResult)
|
||||
ruleResults = self.ResultAdapter.AdaptRuleResults(engineResult)
|
||||
entities = self.ResultAdapter.AdaptEntities(engineResult)
|
||||
structure = self.ResultAdapter.AdaptStructure(engineResult)
|
||||
outline = self.ResultAdapter.AdaptOutline(engineResult)
|
||||
runSummary = self.ResultAdapter.AdaptRunSummary(
|
||||
engineResult,
|
||||
Structure=structure,
|
||||
Outline=outline,
|
||||
)
|
||||
ruleResults = self.ResultAdapter.AdaptRuleResults(engineResult)
|
||||
entities = self.ResultAdapter.AdaptEntities(engineResult)
|
||||
artifacts = self.ResultAdapter.AdaptArtifacts(engineResult, RunId)
|
||||
|
||||
# 将 rules_path 附带到 runSummary 中,供 GetRuleDetail 后续解析
|
||||
runSummary["rulesPath"] = RulesPath
|
||||
|
||||
# 5. 持久化结果
|
||||
await self.Storage.UpdateRunResult(RunId, runSummary)
|
||||
await self.Storage.SaveRuleResults(RunId, ruleResults)
|
||||
|
||||
@@ -73,29 +73,34 @@ class StorageAdapter:
|
||||
log.info(f"[Govdoc] Run status updated: runId={RunId}, status={Status}")
|
||||
|
||||
async def UpdateRunResult(self, RunId: int, Summary: dict[str, Any]) -> None:
|
||||
"""写入 run 结果汇总字段。"""
|
||||
"""写入 run 结果汇总字段(含 rules_path / structure / outline)。"""
|
||||
rules_path = Summary.get("rulesPath")
|
||||
set_clauses = [
|
||||
"total_score = :total_score",
|
||||
"passed_count = :passed_count",
|
||||
"failed_count = :failed_count",
|
||||
"skipped_count = :skipped_count",
|
||||
"result_status = :result_status",
|
||||
"result_summary_json = :result_summary_json",
|
||||
"updated_at = now()",
|
||||
]
|
||||
params: dict[str, Any] = {
|
||||
"rid": RunId,
|
||||
"total_score": Summary.get("totalScore"),
|
||||
"passed_count": Summary.get("passedCount", 0),
|
||||
"failed_count": Summary.get("failedCount", 0),
|
||||
"skipped_count": Summary.get("skippedCount", 0),
|
||||
"result_status": Summary.get("resultStatus"),
|
||||
"result_summary_json": Summary.get("resultSummaryJson"),
|
||||
}
|
||||
if rules_path:
|
||||
set_clauses.append("rules_path = :rules_path")
|
||||
params["rules_path"] = rules_path
|
||||
|
||||
async with GetAsyncSession() as session:
|
||||
await session.execute(
|
||||
text(
|
||||
"""UPDATE govdoc_runs SET
|
||||
total_score = :total_score,
|
||||
passed_count = :passed_count,
|
||||
failed_count = :failed_count,
|
||||
skipped_count = :skipped_count,
|
||||
result_status = :result_status,
|
||||
result_summary_json = :result_summary_json,
|
||||
updated_at = now()
|
||||
WHERE id = :rid"""
|
||||
),
|
||||
{
|
||||
"rid": RunId,
|
||||
"total_score": Summary.get("totalScore"),
|
||||
"passed_count": Summary.get("passedCount", 0),
|
||||
"failed_count": Summary.get("failedCount", 0),
|
||||
"skipped_count": Summary.get("skippedCount", 0),
|
||||
"result_status": Summary.get("resultStatus"),
|
||||
"result_summary_json": Summary.get("resultSummaryJson"),
|
||||
},
|
||||
text(f"UPDATE govdoc_runs SET {', '.join(set_clauses)} WHERE id = :rid"),
|
||||
params,
|
||||
)
|
||||
await session.commit()
|
||||
log.info(f"[Govdoc] Run result saved: runId={RunId}")
|
||||
|
||||
Reference in New Issue
Block a user