AP1.13a: Read-only Gate-Graph aus Abhaengigkeiten.
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Has been cancelled
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Has been cancelled
Initiative-API fuer Roadmap-Dependencies, SVG-Layout mit Liste/Graph-Umschalter auf der Zielzustaende-Seite. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
83fdb9a2a2
commit
7f03504c2d
10 files changed
+712
-2
No files matched your search
@@ -115,6 +115,19 @@ def list_initiative_roadmap_items(
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@initiative_router.get("/{initiative_id}/roadmap/dependencies")
|
||||
def list_initiative_roadmap_dependencies(
|
||||
initiative_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.milestone.read")),
|
||||
):
|
||||
try:
|
||||
return roadmap_service.list_dependencies_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@initiative_router.post("/{initiative_id}/roadmap/items", status_code=201)
|
||||
def create_initiative_roadmap_item(
|
||||
initiative_id: str,
|
||||
|
||||
@@ -484,6 +484,42 @@ def list_dependencies(*, tenant_id: str, item_id: str) -> list[dict[str, Any]]:
|
||||
conn.close()
|
||||
|
||||
|
||||
def list_dependencies_for_initiative(
|
||||
*, tenant_id: str, initiative_id: str
|
||||
) -> list[dict[str, Any]]:
|
||||
if not get_initiative(tenant_id=tenant_id, initiative_id=initiative_id):
|
||||
raise ValueError("Initiative nicht gefunden")
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT d.id, d.tenant_id, d.from_item_id, d.to_item_id,
|
||||
d.dependency_type, d.created_at
|
||||
FROM roadmap_item_dependencies d
|
||||
INNER JOIN roadmap_items fi
|
||||
ON fi.id = d.from_item_id AND fi.tenant_id = d.tenant_id
|
||||
INNER JOIN roadmaps r
|
||||
ON r.id = fi.roadmap_id AND r.tenant_id = fi.tenant_id
|
||||
WHERE d.tenant_id = %s AND r.initiative_id = %s
|
||||
ORDER BY d.created_at ASC
|
||||
""",
|
||||
(tenant_id, initiative_id),
|
||||
)
|
||||
items = []
|
||||
for row in cur.fetchall():
|
||||
dep = dict(row)
|
||||
for key in ("id", "tenant_id", "from_item_id", "to_item_id"):
|
||||
dep[key] = str(dep[key])
|
||||
if dep.get("created_at"):
|
||||
dep["created_at"] = dep["created_at"].isoformat()
|
||||
items.append(dep)
|
||||
return items
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def add_dependency(
|
||||
*,
|
||||
tenant_id: str,
|
||||
|
||||
@@ -120,3 +120,29 @@ def test_steering_snapshot_reads_roadmap_items(client):
|
||||
assert snap.get("roadmap_items")
|
||||
assert snap.get("upcoming_milestones")
|
||||
assert len(snap["upcoming_roadmap_items"]) >= 1
|
||||
|
||||
|
||||
def test_initiative_roadmap_dependencies_list(client):
|
||||
user = provision_user_in_tenant(tenant_role="member")
|
||||
token = _login(client, user)
|
||||
initiative_id = _create_initiative(client, token).json()["id"]
|
||||
gate_a = _create_roadmap_item(client, token, initiative_id, title="Gate A").json()
|
||||
gate_b = _create_roadmap_item(client, token, initiative_id, title="Gate B").json()
|
||||
|
||||
created = client.post(
|
||||
f"/api/roadmap-items/{gate_a['id']}/dependencies",
|
||||
json={"to_item_id": gate_b["id"], "dependency_type": "requires"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert created.status_code == 201
|
||||
|
||||
listed = client.get(
|
||||
f"/api/initiatives/{initiative_id}/roadmap/dependencies",
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert listed.status_code == 200
|
||||
deps = listed.json()
|
||||
assert len(deps) == 1
|
||||
assert deps[0]["from_item_id"] == gate_a["id"]
|
||||
assert deps[0]["to_item_id"] == gate_b["id"]
|
||||
assert deps[0]["dependency_type"] == "requires"
|
||||
Reference in new issue
Block a user