from typing import List, Dict, Any from .base import Formatter from ..types import ReportRow class HTMLFormatter(Formatter): """Форматтер для экспорта отчёта в HTML.""" def __init__(self, **kwargs): super().__init__() def format(self, rows: List[ReportRow]) -> str: # Сгруппируем данные projects: Dict[str, Dict[str, List[ReportRow]]] = {} for r in rows: proj = r["project"] ver = r["version"] if proj not in projects: projects[proj] = {} if ver not in projects[proj]: projects[proj][ver] = [] projects[proj][ver].append(r) lines = [ '
| Наименование Проекта | ", "Номер версии* | ", "Задача | ", "Статус Готовность* | ", "Затрачено за отчетный период | ", "
|---|---|---|---|---|
| {project} | ' ) # Ячейка "Версия" - только в первой строке версии if first_row_in_version: lines.append( f'{version} | ' ) first_row_in_version = False # Остальные колонки task_cell = f"{r['issue_id']}. {r['subject']}" lines.append(f"{task_cell} | ") lines.append(f"{r['status_ru']} | ") lines.append(f"{r['time_text']} | ") lines.append("