kin: KIN-127-backend_dev
This commit is contained in:
parent
a22cf738b7
commit
b431d9358a
2 changed files with 84 additions and 5 deletions
20
web/api.py
20
web/api.py
|
|
@ -660,14 +660,19 @@ def list_tasks(
|
|||
limit: int = Query(default=20, ge=1, le=500),
|
||||
sort: str = Query(default="updated_at"),
|
||||
project_id: str | None = Query(default=None),
|
||||
parent_task_id: str | None = Query(default=None),
|
||||
):
|
||||
"""List tasks with optional filters. sort defaults to updated_at desc."""
|
||||
"""List tasks with optional filters. sort defaults to updated_at desc.
|
||||
|
||||
parent_task_id: filter by parent task. Use '__none__' to get root tasks only.
|
||||
"""
|
||||
from core.models import VALID_TASK_SORT_FIELDS
|
||||
conn = get_conn()
|
||||
tasks = models.list_tasks(
|
||||
conn,
|
||||
project_id=project_id,
|
||||
status=status,
|
||||
parent_task_id=parent_task_id,
|
||||
limit=limit,
|
||||
sort=sort if sort in VALID_TASK_SORT_FIELDS else "updated_at",
|
||||
sort_dir="desc",
|
||||
|
|
@ -686,6 +691,19 @@ def get_task(task_id: str):
|
|||
return t
|
||||
|
||||
|
||||
@app.get("/api/tasks/{task_id}/children")
|
||||
def get_task_children(task_id: str):
|
||||
"""Get direct child tasks of a given task."""
|
||||
conn = get_conn()
|
||||
t = models.get_task(conn, task_id)
|
||||
if not t:
|
||||
conn.close()
|
||||
raise HTTPException(404, f"Task '{task_id}' not found")
|
||||
children = models.get_children(conn, task_id)
|
||||
conn.close()
|
||||
return children
|
||||
|
||||
|
||||
class TaskCreate(BaseModel):
|
||||
project_id: str
|
||||
title: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue