From 699ef15ee202ba4a1323d892c0b1677d8381cb19 Mon Sep 17 00:00:00 2001 From: tegwick Date: Mon, 22 Jun 2026 13:52:13 +0200 Subject: [PATCH] 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. --- hub_core/routers/progress.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hub_core/routers/progress.py b/hub_core/routers/progress.py index 74877d7..63cf048 100644 --- a/hub_core/routers/progress.py +++ b/hub_core/routers/progress.py @@ -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,