36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
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)
|