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

@@ -63,6 +63,7 @@ def build_grouped_report(
"subject": issue.subject,
"status_ru": status_ru,
"time_text": time_text,
"hours": round(hours, 2),
},
)
)
@@ -73,6 +74,26 @@ def build_grouped_report(
return rows
def calculate_summary(rows: List[ReportRow]) -> Dict[str, float]:
"""Возвращает сводку: общее время, время по проектам и версиям."""
total = 0.0
by_project: Dict[str, float] = {}
by_project_version: Dict[str, float] = {}
for r in rows:
hours = r.get("hours", 0.0)
total += hours
by_project[r["project"]] = by_project.get(r["project"], 0.0) + hours
key = f"{r['project']}::{r['version']}"
by_project_version[key] = by_project_version.get(key, 0.0) + hours
return {
"total": round(total, 2),
**{f"project:{k}": round(v, 2) for k, v in by_project.items()},
**{f"version:{k}": round(v, 2) for k, v in by_project_version.items()},
}
def group_rows_by_project_and_version(
rows: List[ReportRow],
) -> Dict[str, Dict[str, List[ReportRow]]]: