Extract grouping logic into shared function (#19)
Add group_rows_by_project_and_version() to report_builder.py and replace the duplicated inline grouping in both html.py and odt.py with a single call to the shared function. This ensures consistent grouping behavior across formatters and removes a maintenance burden — any change to grouping logic now happens in one place. Closes #19
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from html import escape
|
||||
from typing import Dict, List
|
||||
from typing import List
|
||||
|
||||
from ..report_builder import group_rows_by_project_and_version
|
||||
from ..types import ReportRow
|
||||
from .base import Formatter
|
||||
|
||||
@@ -12,16 +13,7 @@ class HTMLFormatter(Formatter):
|
||||
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)
|
||||
projects = group_rows_by_project_and_version(rows)
|
||||
|
||||
lines = [
|
||||
'<table border="1" cellpadding="6" cellspacing="0" style="border-collapse: collapse; font-family: Arial, sans-serif;">',
|
||||
|
||||
Reference in New Issue
Block a user