fix(workbench): serialize events and target work order sync
This commit is contained in:
@@ -122,12 +122,17 @@ async def list_operational_tasks(
|
||||
task_status: TaskStatus | None = Query(default=None, alias="status"),
|
||||
limit: int = Query(default=50, ge=1, le=100),
|
||||
offset: int = Query(default=0, ge=0),
|
||||
peripheral_work_order_id: UUID | None = Query(
|
||||
default=None, description="Only tasks sourced from or linked to this peripheral work order",
|
||||
),
|
||||
ctx: ProjectContext = Depends(require_permission(OPERATIONAL_TASK_VIEW)),
|
||||
conn: AsyncConnection = Depends(get_project_pg_connection),
|
||||
):
|
||||
try:
|
||||
items, next_offset = await _service(ctx, conn).list(
|
||||
task_type=task_type, status=task_status, limit=limit, offset=offset
|
||||
task_type=task_type, status=task_status, limit=limit, offset=offset,
|
||||
**({"peripheral_work_order_id": peripheral_work_order_id}
|
||||
if peripheral_work_order_id is not None else {}),
|
||||
)
|
||||
return OperationalTaskPage(
|
||||
items=items, limit=limit, offset=offset, next_offset=next_offset
|
||||
|
||||
@@ -131,9 +131,9 @@ async def workbench_events(
|
||||
if now - last_keepalive >= 15:
|
||||
yield f": keepalive {int(now)}\n\n"
|
||||
last_keepalive = now
|
||||
# LISTEN is only a wake-up path. The timeout also reconciles
|
||||
# against the durable cursor if a notification was missed.
|
||||
wake_generation = await hub.wait_for_wake(wake_generation, timeout=1)
|
||||
# The Hub invalidates shared reads on NOTIFY and every 30s.
|
||||
# Per-client timeout only keeps the transport alive, not SQL.
|
||||
wake_generation = await hub.wait_for_wake(wake_generation, timeout=15)
|
||||
yield "event: reconnect\ndata: {}\n\n"
|
||||
|
||||
return StreamingResponse(
|
||||
|
||||
Reference in New Issue
Block a user