feat: JSON, Excel export and time summary

- #23: add JSONFormatter and XLSXFormatter
- add openpyxl dependency for .xlsx export
- #22: add --summary flag and calculate_summary() in report_builder
- ReportRow now carries raw hours for summary calculations
- update CLI help and README with .json/.xlsx formats and --summary
- add tests for new formatters and summary computation

Closes #22, closes #23
This commit is contained in:
Кокос Артем Николаевич
2026-06-29 12:09:58 +07:00
parent f6afc4096d
commit ca89832d74
11 changed files with 255 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
import json
from typing import List
from ..types import ReportRow
from .base import Formatter
class JSONFormatter(Formatter):
"""Форматтер для экспорта отчёта в JSON."""
def __init__(self, **_kwargs):
super().__init__()
def format(self, rows: List[ReportRow]) -> str:
data = [
{
"project": r["project"],
"version": r["version"],
"issue_id": r["issue_id"],
"subject": r["subject"],
"status": r["status_ru"],
"time": r["time_text"],
}
for r in rows
]
return json.dumps(data, ensure_ascii=False, indent=2)
def save(self, rows: List[ReportRow], output_path: str) -> None:
content = self.format(rows)
with open(output_path, "w", encoding="utf-8") as f:
f.write(content)