fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s

This commit is contained in:
emmatveev 2024-11-27 02:08:05 +03:00
parent 2ff6c22e0b
commit f35115d2f2

View File

@ -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))