feat(A1): Activity Set am Gate-Detail — Übungen an Zielzustand binden
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 4m54s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 13s
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 4m54s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 13s
Gate-Detail: Übungen anlegen mit Rhythmus, Gate aktivieren, Link zu Today. API: /roadmap-items/{id}/practices und roadmap_item_id auf Recurring-Create. Damit ist A1 ohne Starter-Kit manuell durchspielbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
17add13d9d
commit
87ecee5301
11 files changed
+473
-5
No files matched your search
@@ -132,6 +132,7 @@ class RecurringCreateRequest(BaseModel):
|
||||
status: Literal["active", "paused", "ended"] = "active"
|
||||
interval_days: Optional[int] = Field(default=None, gt=0)
|
||||
next_due_at: Optional[str] = None
|
||||
roadmap_item_id: Optional[str] = None
|
||||
|
||||
|
||||
def _parse_optional_datetime(value: Optional[str], field_name: str) -> Optional[datetime]:
|
||||
@@ -648,6 +649,7 @@ def create_initiative_recurring(
|
||||
status=body.status,
|
||||
interval_days=body.interval_days,
|
||||
next_due_at=next_due_at,
|
||||
roadmap_item_id=body.roadmap_item_id,
|
||||
user_id=ctx.user_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
|
||||
@@ -22,6 +22,8 @@ class RecurringUpdateRequest(BaseModel):
|
||||
clear_interval_days: bool = False
|
||||
next_due_at: Optional[str] = None
|
||||
clear_next_due_at: bool = False
|
||||
roadmap_item_id: Optional[str] = None
|
||||
clear_roadmap_item_id: bool = False
|
||||
|
||||
|
||||
class RecurringCompleteRequest(BaseModel):
|
||||
@@ -69,6 +71,8 @@ def update_recurring_element(
|
||||
clear_interval_days=body.clear_interval_days,
|
||||
next_due_at=next_due_at,
|
||||
clear_next_due_at=body.clear_next_due_at,
|
||||
roadmap_item_id=body.roadmap_item_id,
|
||||
clear_roadmap_item_id=body.clear_roadmap_item_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
@@ -87,6 +87,13 @@ class ReopenRequest(BaseModel):
|
||||
reason: str = ""
|
||||
|
||||
|
||||
class GatePracticeCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
description: str = ""
|
||||
status: Literal["active", "paused", "ended"] = "active"
|
||||
interval_days: int = Field(default=1, gt=0)
|
||||
|
||||
|
||||
class PlanSnapshotCreateRequest(BaseModel):
|
||||
reason: str = Field(default="", max_length=2000)
|
||||
|
||||
@@ -309,6 +316,63 @@ def delete_roadmap_item(
|
||||
raise HTTPException(status_code=404, detail="RoadmapItem nicht gefunden")
|
||||
|
||||
|
||||
def _work_gate_or_400(*, tenant_id: str, item_id: str) -> dict[str, Any]:
|
||||
item = roadmap_service.get_roadmap_item(tenant_id=tenant_id, item_id=item_id)
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="RoadmapItem nicht gefunden")
|
||||
if item.get("item_type") == "join_gate":
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Join-Gates haben kein Activity Set (Übungen)",
|
||||
)
|
||||
return item
|
||||
|
||||
|
||||
@items_router.get("/{item_id}/practices")
|
||||
def list_gate_practices(
|
||||
item_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.recurring.read")),
|
||||
):
|
||||
from services import recurring as recurring_service
|
||||
|
||||
item = _work_gate_or_400(tenant_id=ctx.tenant_id, item_id=item_id)
|
||||
try:
|
||||
return recurring_service.list_recurring_for_gate(
|
||||
tenant_id=ctx.tenant_id,
|
||||
initiative_id=str(item["initiative_id"]),
|
||||
gate_id=item_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@items_router.post("/{item_id}/practices", status_code=201)
|
||||
def create_gate_practice(
|
||||
item_id: str,
|
||||
body: GatePracticeCreateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.recurring.manage")),
|
||||
):
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from services import recurring as recurring_service
|
||||
|
||||
item = _work_gate_or_400(tenant_id=ctx.tenant_id, item_id=item_id)
|
||||
try:
|
||||
return recurring_service.create_recurring_element(
|
||||
tenant_id=ctx.tenant_id,
|
||||
initiative_id=str(item["initiative_id"]),
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
status=body.status,
|
||||
interval_days=body.interval_days,
|
||||
next_due_at=datetime.now(timezone.utc),
|
||||
roadmap_item_id=item_id,
|
||||
user_id=ctx.user_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@items_router.post("/{item_id}/verify-reached")
|
||||
def verify_roadmap_item_reached(
|
||||
item_id: str,
|
||||
|
||||
Reference in new issue
Block a user