checkpoint
This commit is contained in:
@@ -19,6 +19,7 @@ from core.security import get_current_user, validate_access_to_resource
|
||||
from api.v1.modules.core.tasks_tracking import track_and_dispatch
|
||||
|
||||
from ..common.track_commit_dispatch import dispatch_tracked_layouts_csv_commit
|
||||
from ..common.responses import normalize_commit_status_payload
|
||||
from .schemas import ImportJobResponse
|
||||
from .tasks import (
|
||||
scan_file,
|
||||
@@ -133,12 +134,12 @@ async def get_import_status(job_id: str):
|
||||
if task_result.state == "SUCCESS":
|
||||
result = task_result.result
|
||||
if isinstance(result, dict) and "status" in result:
|
||||
return result
|
||||
return normalize_commit_status_payload(result)
|
||||
return {"status": "finished", "result": result}
|
||||
|
||||
result = getattr(task_result, "result", None)
|
||||
if isinstance(result, dict) and result.get("status") in ("finished", "warning"):
|
||||
return result
|
||||
return normalize_commit_status_payload(result)
|
||||
|
||||
# Si Celery devolvió el resultado como string (p. ej. JSON), parsear y devolver como scan si aplica
|
||||
if isinstance(result, str):
|
||||
@@ -150,7 +151,7 @@ async def get_import_status(job_id: str):
|
||||
):
|
||||
return parsed
|
||||
if isinstance(parsed, dict) and parsed.get("status") in ("finished", "warning"):
|
||||
return parsed
|
||||
return normalize_commit_status_payload(parsed)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
pass
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ def scan_file(self, job_id: str, config: str = None):
|
||||
try:
|
||||
with open(error_path, "w", encoding="utf-8") as f_err:
|
||||
for i, row in common_csv.iter_csv_rows(file_path, fieldnames=fieldnames):
|
||||
if i % 500 == 0:
|
||||
self.update_state(
|
||||
self.update_state(
|
||||
state="PROGRESS",
|
||||
meta={"current": i, "total": total_rows, "errors": error_count},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user