排程管理及排程记录查看功能
This commit is contained in:
1 parent
3b31867319
commit
08776feef2
28 files changed
+3040
-8
No files matched your search
@@ -0,0 +1,45 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
|
||||
def export_schedule_result_excel(*, run_no: str, summary: dict, details: list[dict], root_dir: str) -> tuple[str | None, str | None, int]:
|
||||
if not details:
|
||||
return None, None, 0
|
||||
|
||||
out_root = Path(root_dir)
|
||||
out_root.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
rows: list[dict[str, Any]] = []
|
||||
for row in details:
|
||||
output = row.get('dify_output')
|
||||
if not isinstance(output, dict):
|
||||
output = {}
|
||||
entry = dict(output)
|
||||
for k in ('writeback_ok', 'error'):
|
||||
if k in row:
|
||||
entry[k] = row[k]
|
||||
rows.append(entry)
|
||||
|
||||
headers: list[str] = []
|
||||
for row in rows:
|
||||
for k in row:
|
||||
if k not in headers:
|
||||
headers.append(k)
|
||||
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = 'result'
|
||||
ws.append(headers)
|
||||
|
||||
for row in rows:
|
||||
ws.append([row.get(k, '') for k in headers])
|
||||
|
||||
file_name = f'schedule_{run_no}.xlsx'
|
||||
file_path = out_root / file_name
|
||||
wb.save(file_path)
|
||||
size = file_path.stat().st_size
|
||||
return str(file_path), file_name, int(size)
|
||||
Reference in new issue
Block a user