Fixed Taiga integration

This commit is contained in:
2026-06-09 13:31:01 +03:00
parent 1f83dcb574
commit fb7c4f34b7
5 changed files with 181 additions and 36 deletions
+57
View File
@@ -366,6 +366,63 @@ class ProjectService:
item.status = "closed"
item.closed_at = datetime.now(timezone.utc)
def list_taiga_open_tasks(
self,
project_slug: str | None = None,
limit: int = 20,
) -> dict[str, Any]:
if not self.settings.taiga_configured:
raise ValueError("Taiga не настроена")
projects = self.list_projects()
if not projects:
projects = self.sync_taiga_projects()
if project_slug:
projects = [p for p in projects if p["slug"] == project_slug]
if not projects:
raise ValueError(
f"Проект '{project_slug}' не найден. Вызови sync_taiga_projects."
)
client = TaigaClient()
blocks: list[dict[str, Any]] = []
for proj in projects:
stories = client.list_open_userstories(proj["taiga_id"], limit=limit)
tasks = client.list_open_tasks(proj["taiga_id"], limit=limit)
blocks.append(
{
"slug": proj["slug"],
"name": proj["name"],
"taiga_id": proj["taiga_id"],
"stories": [
{
"ref": s.get("ref"),
"subject": s.get("subject", ""),
"url": client.story_url(proj["taiga_id"], s.get("ref", 0)),
}
for s in stories
],
"tasks": [
{
"ref": t.get("ref"),
"subject": t.get("subject", ""),
"user_story": t.get("user_story"),
}
for t in tasks
],
}
)
total_stories = sum(len(b["stories"]) for b in blocks)
total_tasks = sum(len(b["tasks"]) for b in blocks)
return {
"projects": blocks,
"total_stories": total_stories,
"total_tasks": total_tasks,
}
def list_work_items(self, limit: int = 30, status: str | None = None) -> list[dict[str, Any]]:
stmt = select(WorkItem).order_by(WorkItem.created_at.desc()).limit(limit)
if status: