checkpoint
This commit is contained in:
@@ -72,3 +72,36 @@ def commit_result(
|
||||
if error:
|
||||
out["error"] = error
|
||||
return out
|
||||
|
||||
|
||||
def normalize_commit_status_payload(d: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Homogeneiza respuestas de commit CSV (finished / warning) al contrato usado por pedimentos:
|
||||
inserted, updated, skipped_*, skipped_details, skipped_summary, critical_reference_gaps,
|
||||
reference_state_ready. No modifica waiting_confirmation ni otros status.
|
||||
"""
|
||||
if not isinstance(d, dict):
|
||||
return d
|
||||
st = d.get("status")
|
||||
if st not in ("finished", "warning"):
|
||||
return d
|
||||
out = dict(d)
|
||||
out.setdefault("inserted", 0)
|
||||
out.setdefault("updated", 0)
|
||||
out.setdefault("skipped_invalid", 0)
|
||||
out.setdefault("skipped_missing_fk", 0)
|
||||
out.setdefault("skipped_duplicate", 0)
|
||||
out.setdefault("skipped_missing_invoice", 0)
|
||||
details = out.get("skipped_details")
|
||||
if not isinstance(details, list):
|
||||
out["skipped_details"] = []
|
||||
else:
|
||||
out["skipped_details"] = details
|
||||
out.setdefault("critical_reference_gaps", 0)
|
||||
if "reference_state_ready" not in out:
|
||||
out["reference_state_ready"] = out.get("critical_reference_gaps", 0) == 0
|
||||
if "skipped_summary" not in out:
|
||||
out["skipped_summary"] = (
|
||||
_summarize_reasons(out["skipped_details"], "reason") if out["skipped_details"] else []
|
||||
)
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user