35
redmine_reporter/formatter_md.py
Normal file
35
redmine_reporter/formatter_md.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from typing import List, Tuple
|
||||
from redminelib.resources import Issue
|
||||
from .formatter import get_version, hours_to_human, STATUS_TRANSLATION
|
||||
|
||||
|
||||
def format_md(issue_hours: List[Tuple[Issue, float]], fill_time: bool = True) -> str:
|
||||
"""
|
||||
Formats the list of issues with spent time into a Markdown table.
|
||||
Returns a string containing the Markdown content.
|
||||
"""
|
||||
|
||||
lines = []
|
||||
lines.append("| Проект | Версия | Задача | Статус | Затрачено |")
|
||||
lines.append("|--------|--------|--------|--------|-----------|")
|
||||
|
||||
prev_project = None
|
||||
prev_version = None
|
||||
|
||||
for issue, hours in issue_hours:
|
||||
project = str(issue.project)
|
||||
version = get_version(issue)
|
||||
status_en = str(issue.status)
|
||||
status_ru = STATUS_TRANSLATION.get(status_en, status_en)
|
||||
time_text = hours_to_human(hours) if fill_time else ""
|
||||
|
||||
display_project = project if project != prev_project else ""
|
||||
display_version = version if (project != prev_project or version != prev_version) else ""
|
||||
|
||||
task_cell = f"{issue.id}. {issue.subject}"
|
||||
lines.append(f"| {display_project} | {display_version} | {task_cell} | {status_ru} | {time_text} |")
|
||||
|
||||
prev_project = project
|
||||
prev_version = version
|
||||
|
||||
return "\n".join(lines)
|
||||
Reference in New Issue
Block a user