From f35115d2f2e3d191a57978df6b71911569d25c11 Mon Sep 17 00:00:00 2001 From: emmatveev Date: Wed, 27 Nov 2024 02:08:05 +0300 Subject: [PATCH] fix --- app/routers/take.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/routers/take.py b/app/routers/take.py index f0cd112..5085ce7 100644 --- a/app/routers/take.py +++ b/app/routers/take.py @@ -9,10 +9,17 @@ from app.storage import redis router = fastapi.APIRouter() +class Task(pydantic.BaseModel): + id: str + attempt: int + payload: dict + + class Response(pydantic.BaseModel): id: str attempt: int payload: dict + task: Task|None @router.get('/api/v1/take', responses={404: {'description': 'Not found'}}) @@ -20,4 +27,4 @@ async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response: task = await tasks.take_task(queue) if not task: raise fastapi.HTTPException(404) - return Response(id=str(task._id), attempt=task.attempts, payload=task.payload) + return Response(id=str(task._id), attempt=task.attempts, payload=task.payload, task=Task(id=str(task._id), attempt=task.attempts, payload=task.payload))