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:
@@ -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]]]:
|
||||
|
||||
Reference in New Issue
Block a user