fix: Update delete_job endpoint to return a Response object instead of None. Enhance import statements by adding Response to improve API response handling.
This commit is contained in:
@@ -15,7 +15,7 @@ except ImportError:
|
||||
_RedisSettings = None # type: ignore[assignment]
|
||||
_ARQ_AVAILABLE = False
|
||||
|
||||
from fastapi import BackgroundTasks, FastAPI, File, Form, HTTPException, UploadFile
|
||||
from fastapi import BackgroundTasks, FastAPI, File, Form, HTTPException, Response, UploadFile
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
from sqlalchemy import delete, select
|
||||
|
||||
@@ -1046,8 +1046,8 @@ def get_job_tasks(job_id: str) -> list[dict[str, Any]]:
|
||||
return [serialize_task(t) for t in tasks]
|
||||
|
||||
|
||||
@app.delete("/jobs/{job_id}", status_code=204)
|
||||
def delete_job(job_id: str) -> None:
|
||||
@app.delete("/jobs/{job_id}", status_code=204, response_class=Response)
|
||||
def delete_job(job_id: str) -> Response:
|
||||
"""Elimina un job y todos sus resultados (tasks, conteos, extracciones, limpiezas)."""
|
||||
with session_scope() as session:
|
||||
job = session.get(Job, job_id)
|
||||
@@ -1091,6 +1091,7 @@ def delete_job(job_id: str) -> None:
|
||||
|
||||
session.delete(job)
|
||||
session.flush()
|
||||
return Response(status_code=204)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user