generated from coulomb/repo-seed
fix(progress): accept workplan_id filter alongside legacy workstream_id
STATE-WP-0065 renamed progress_event.workstream_id to workplan_id in state-hub; the list endpoint now maps both query params to the model column.
This commit is contained in:
@@ -28,6 +28,7 @@ def create_progress_router(
|
||||
*,
|
||||
topic_id: uuid.UUID | None = None,
|
||||
workstream_id: uuid.UUID | None = None,
|
||||
workplan_id: uuid.UUID | None = None,
|
||||
task_id: uuid.UUID | None = None,
|
||||
decision_id: uuid.UUID | None = None,
|
||||
event_type: str | None = None,
|
||||
@@ -37,9 +38,9 @@ def create_progress_router(
|
||||
offset: int = 0,
|
||||
) -> list[Any]:
|
||||
q = select(progress_model)
|
||||
scope_id = workplan_id if workplan_id is not None else workstream_id
|
||||
for field, value in (
|
||||
("topic_id", topic_id),
|
||||
("workstream_id", workstream_id),
|
||||
("task_id", task_id),
|
||||
("decision_id", decision_id),
|
||||
):
|
||||
@@ -51,6 +52,16 @@ def create_progress_router(
|
||||
detail=f"Progress events do not support filtering by {field}",
|
||||
)
|
||||
q = q.where(column == value)
|
||||
if scope_id is not None:
|
||||
column = getattr(progress_model, "workplan_id", None) or getattr(
|
||||
progress_model, "workstream_id", None
|
||||
)
|
||||
if column is None:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Progress events do not support filtering by workplan_id",
|
||||
)
|
||||
q = q.where(column == scope_id)
|
||||
if event_type:
|
||||
q = q.where(progress_model.event_type == event_type)
|
||||
if event_types is not None:
|
||||
@@ -66,6 +77,7 @@ def create_progress_router(
|
||||
async def list_progress(
|
||||
topic_id: uuid.UUID | None = None,
|
||||
workstream_id: uuid.UUID | None = None,
|
||||
workplan_id: uuid.UUID | None = None,
|
||||
task_id: uuid.UUID | None = None,
|
||||
decision_id: uuid.UUID | None = None,
|
||||
event_type: str | None = None,
|
||||
@@ -78,6 +90,7 @@ def create_progress_router(
|
||||
session,
|
||||
topic_id=topic_id,
|
||||
workstream_id=workstream_id,
|
||||
workplan_id=workplan_id,
|
||||
task_id=task_id,
|
||||
decision_id=decision_id,
|
||||
event_type=event_type,
|
||||
|
||||
Reference in New Issue
Block a user