feat: release 2.3.0 with workspace plugin extensions
This commit is contained in:
1 parent
8380057548
commit
bb873ec0e0
44 files changed
+1497
-48
No files matched your search
@@ -15,6 +15,7 @@ from apps.admin_console.services.export_cache import (
|
||||
)
|
||||
from apps.admin_console.services.request_diagnostics import diagnostics_json
|
||||
from apps.admin_console.services.task_lifecycle import guidance_details
|
||||
from apps.admin_console.services import task_extensions
|
||||
|
||||
from docx import Document
|
||||
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
|
||||
@@ -36,6 +37,31 @@ from apps.admin_console.services.case_review import reviewed_result
|
||||
|
||||
EXPORT_ROOT = WORKSPACE_ROOT / "artifacts" / "reports"
|
||||
BATCH_ARCHIVE_SIGNATURE = "artemis-batch-layout-2"
|
||||
|
||||
|
||||
def batch_archive_signature(batch_id: str | None = None) -> str:
|
||||
signature = task_extensions.installation_signature()
|
||||
if batch_id:
|
||||
with store.connection() as conn:
|
||||
changes = conn.execute(
|
||||
"SELECT r.id,r.updated_at FROM automation_records r "
|
||||
"JOIN automation_jobs j ON j.session_id=r.id "
|
||||
"WHERE r.kind='task_extensions' AND j.batch_id=? ORDER BY r.id",
|
||||
(batch_id,),
|
||||
).fetchall()
|
||||
if changes:
|
||||
signature += ":" + fingerprint({"reviews": [tuple(row) for row in changes]})
|
||||
return BATCH_ARCHIVE_SIGNATURE + (":" + signature if signature else "")
|
||||
|
||||
|
||||
def extension_rows(report: dict) -> list[tuple[str, str, str]]:
|
||||
return [
|
||||
(section["name"], field["label"], field["value"])
|
||||
for section in report.get("task_extensions", [])
|
||||
for field in section["fields"]
|
||||
]
|
||||
|
||||
|
||||
STATUS = {
|
||||
"completed": "执行完成",
|
||||
"success": "执行完成",
|
||||
@@ -239,6 +265,7 @@ def session_report(session_id: str, db_path=None) -> dict:
|
||||
"subcategory": case.get("subcategory", ""),
|
||||
"preconditions": case.get("preconditions", ""),
|
||||
"task_config": case.get("task_config") or {},
|
||||
"task_extensions": task_extensions.report_sections(session_id, store),
|
||||
}
|
||||
|
||||
|
||||
@@ -659,6 +686,11 @@ def word_report(report: dict, path: Path):
|
||||
doc.add_paragraph("任务配置:" + config_text(report["task_config"]))
|
||||
doc.add_heading("结论与发现", 1)
|
||||
add_markdown_content(doc, report["content"])
|
||||
if review_rows := extension_rows(report):
|
||||
doc.add_heading("人工评审(插件)", 1)
|
||||
word_table(
|
||||
doc, [(f"{name} · {label}", value) for name, label, value in review_rows], (5.5, 11)
|
||||
)
|
||||
doc.add_heading("执行步骤与证据", 1)
|
||||
for step in report["steps"]:
|
||||
paragraph = doc.add_paragraph()
|
||||
@@ -792,6 +824,10 @@ def excel_report(report: dict, path: Path):
|
||||
wb.active.title = "任务结果"
|
||||
sheet_rows(wb.active, [("项目", "内容"), *metadata(report)], (22, 82))
|
||||
sheet_rows(wb.create_sheet("结论"), conclusion_rows(report["content"]), (15, 96))
|
||||
if review_rows := extension_rows(report):
|
||||
sheet_rows(
|
||||
wb.create_sheet("人工评审"), [("插件", "项目", "内容"), *review_rows], (24, 30, 82)
|
||||
)
|
||||
table_number = 0
|
||||
for kind, rows in markdown_blocks(report["content"]):
|
||||
if kind == "table":
|
||||
@@ -1064,7 +1100,9 @@ def export_batch(batch_id: str, progress: Callable[[int, int, str], None] | None
|
||||
directory = EXPORT_ROOT / "batches" / batch_id
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
formats = batch["formats"]
|
||||
records = [session_report(job["session_id"]) for job in store.jobs(batch_id)]
|
||||
with task_extensions.plugin_store().mutation_lock:
|
||||
signature = batch_archive_signature(batch_id)
|
||||
records = [session_report(job["session_id"]) for job in store.jobs(batch_id)]
|
||||
if progress:
|
||||
progress(0, len(records), "正在生成批次汇总")
|
||||
rows = [("任务编号", "任务名称", "执行状态", "验证结论", "异常原因")]
|
||||
@@ -1078,6 +1116,17 @@ def export_batch(batch_id: str, progress: Callable[[int, int, str], None] | None
|
||||
assert wb.active is not None
|
||||
wb.active.title = "批次结果"
|
||||
sheet_rows(wb.active, rows, (40, 48, 16, 28, 70))
|
||||
review_rows = [
|
||||
(record["id"], record["name"], *row)
|
||||
for record in records
|
||||
for row in extension_rows(record)
|
||||
]
|
||||
if review_rows:
|
||||
sheet_rows(
|
||||
wb.create_sheet("人工评审"),
|
||||
[("任务编号", "任务名称", "插件", "项目", "内容"), *review_rows],
|
||||
(40, 40, 24, 30, 70),
|
||||
)
|
||||
path = directory / "批次结果.xlsx"
|
||||
wb.save(path)
|
||||
outputs.append(path)
|
||||
@@ -1088,6 +1137,15 @@ def export_batch(batch_id: str, progress: Callable[[int, int, str], None] | None
|
||||
f"批次编号:{batch_id};共 {len(records)} 个任务。验证通过与执行完成分别统计。"
|
||||
)
|
||||
word_table(doc, rows, (3.5, 5.4, 2.5, 3.5, 7.3), header=True)
|
||||
for record in records:
|
||||
if review_rows := extension_rows(record):
|
||||
doc.add_heading("人工评审 · " + record["name"], 1)
|
||||
doc.add_paragraph("任务编号:" + record["id"])
|
||||
word_table(
|
||||
doc,
|
||||
[(f"{name} · {label}", value) for name, label, value in review_rows],
|
||||
(7, 15.2),
|
||||
)
|
||||
path = directory / "批次汇总.docx"
|
||||
doc.save(str(path))
|
||||
outputs.append(path)
|
||||
@@ -1146,5 +1204,5 @@ def export_batch(batch_id: str, progress: Callable[[int, int, str], None] | None
|
||||
if progress:
|
||||
progress(len(records), len(records), "正在完成压缩包")
|
||||
temporary.replace(target)
|
||||
remember(target, BATCH_ARCHIVE_SIGNATURE)
|
||||
remember(target, signature)
|
||||
return target
|
||||
Reference in new issue
Block a user