feat(schedule): einheitliche Rhythmus-Schicht an Gate und Arbeitspaket
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Successful in 4m57s
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 18s
Test Suite / playwright-smoke (push) Successful in 12s
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Successful in 4m57s
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 18s
Test Suite / playwright-smoke (push) Successful in 12s
Bestehende Recurring-Pfade bleiben kompatibel (interval_days-Fallback, Migration backfillt schedules), damit der aktuelle Betrieb nicht bricht und der Stand auf einem zweiten Rechner weitergebaut werden kann. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
87ecee5301
commit
ea0aa18b8d
21 files changed
+1608
-59
No files matched your search
@@ -9,7 +9,9 @@ from capabilities import require_capability
|
||||
from data_layer import actions as dl_actions
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from schemas.schedule_payload import SchedulePayload
|
||||
from services import actions as action_service
|
||||
from services import scheduled_work as scheduled_work_service
|
||||
from services import tasks as task_service
|
||||
from tenant_context import TenantContext
|
||||
|
||||
@@ -155,6 +157,47 @@ def update_action(
|
||||
return item
|
||||
|
||||
|
||||
@router.put("/{action_id}/schedule")
|
||||
def upsert_action_schedule(
|
||||
action_id: str,
|
||||
body: SchedulePayload,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.action.manage")),
|
||||
):
|
||||
try:
|
||||
return scheduled_work_service.upsert_action_schedule(
|
||||
tenant_id=ctx.tenant_id,
|
||||
action_id=action_id,
|
||||
user_id=ctx.user_id,
|
||||
schedule_kind=body.schedule_kind,
|
||||
interval_days=body.interval_days,
|
||||
weekday_mask=body.weekday_mask,
|
||||
pause_until=body.pause_until_date(),
|
||||
)
|
||||
except ValueError as exc:
|
||||
detail = str(exc)
|
||||
if detail == "Arbeitspaket nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
|
||||
|
||||
@router.delete("/{action_id}/schedule", status_code=200)
|
||||
def clear_action_schedule(
|
||||
action_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.action.manage")),
|
||||
):
|
||||
try:
|
||||
return scheduled_work_service.clear_action_schedule(
|
||||
tenant_id=ctx.tenant_id,
|
||||
action_id=action_id,
|
||||
user_id=ctx.user_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
detail = str(exc)
|
||||
if detail == "Arbeitspaket nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
|
||||
|
||||
@router.put("/{action_id}/assignments")
|
||||
def set_action_assignments(
|
||||
action_id: str,
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import Literal, Optional
|
||||
from capabilities import require_capability
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from schemas.schedule_payload import SchedulePayload
|
||||
from services import recurring as recurring_service
|
||||
from tenant_context import TenantContext
|
||||
|
||||
@@ -24,6 +25,7 @@ class RecurringUpdateRequest(BaseModel):
|
||||
clear_next_due_at: bool = False
|
||||
roadmap_item_id: Optional[str] = None
|
||||
clear_roadmap_item_id: bool = False
|
||||
schedule: Optional[SchedulePayload] = None
|
||||
|
||||
|
||||
class RecurringCompleteRequest(BaseModel):
|
||||
@@ -59,6 +61,7 @@ def update_recurring_element(
|
||||
ctx: TenantContext = Depends(require_capability("kairo.recurring.manage")),
|
||||
):
|
||||
next_due_at = _parse_datetime(body.next_due_at) if body.next_due_at is not None else None
|
||||
sched = body.schedule
|
||||
try:
|
||||
item = recurring_service.update_recurring_element(
|
||||
tenant_id=ctx.tenant_id,
|
||||
@@ -67,12 +70,16 @@ def update_recurring_element(
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
status=body.status,
|
||||
interval_days=body.interval_days,
|
||||
interval_days=body.interval_days if sched is None else sched.interval_days,
|
||||
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,
|
||||
schedule_kind=sched.schedule_kind if sched else None,
|
||||
weekday_mask=sched.weekday_mask if sched else None,
|
||||
pause_until=sched.pause_until_date() if sched else None,
|
||||
clear_pause_until=sched is not None and sched.pause_until is None,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import Any, Literal, Optional
|
||||
from capabilities import require_capability
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from schemas.schedule_payload import SchedulePayload
|
||||
from services import roadmap as roadmap_service
|
||||
from services import roadmap_criteria as criteria_service
|
||||
from services import roadmap_plan_snapshot as snapshot_service
|
||||
@@ -92,6 +93,7 @@ class GatePracticeCreateRequest(BaseModel):
|
||||
description: str = ""
|
||||
status: Literal["active", "paused", "ended"] = "active"
|
||||
interval_days: int = Field(default=1, gt=0)
|
||||
schedule: Optional[SchedulePayload] = None
|
||||
|
||||
|
||||
class PlanSnapshotCreateRequest(BaseModel):
|
||||
@@ -352,12 +354,25 @@ def create_gate_practice(
|
||||
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)
|
||||
sched = body.schedule
|
||||
try:
|
||||
if sched:
|
||||
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,
|
||||
schedule_kind=sched.schedule_kind,
|
||||
interval_days=sched.interval_days,
|
||||
weekday_mask=sched.weekday_mask,
|
||||
pause_until=sched.pause_until_date(),
|
||||
roadmap_item_id=item_id,
|
||||
user_id=ctx.user_id,
|
||||
)
|
||||
return recurring_service.create_recurring_element(
|
||||
tenant_id=ctx.tenant_id,
|
||||
initiative_id=str(item["initiative_id"]),
|
||||
@@ -365,7 +380,6 @@ def create_gate_practice(
|
||||
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,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user