fix: process.py — use apply_ops() instead of phantom add_row/update_row/delete_row
Deploy contracts-flask / validate (push) Successful in 0s

This commit is contained in:
2026-07-16 08:09:29 +04:00
parent e4c010acd3
commit 04cb3f5bfe
+14 -20
View File
@@ -86,27 +86,21 @@ def run_pipeline(contract_id, order_ids, build_prompt_fn):
"time_s": round(time.time() - t1, 1),
}
# Apply ops to DB
applied_ops = []
summary = {"added": 0, "updated": 0, "deleted": 0, "unresolved": 0}
for op in ops:
action = op.get("action", "UNRESOLVED")
summary[action.lower()] = summary.get(action.lower(), 0) + 1
# Apply ops to DB via apply_ops
try:
if action == "ADD":
nr = op.get("new_row", {})
spec_events.add_row(contract_id, sid, nr)
elif action == "UPDATE":
nr = op.get("new_row", {})
nv = op.get("new_values", {})
target = op.get("target_hash", "")
spec_events.update_row(contract_id, sid, target, nr, nv)
elif action == "DELETE":
target = op.get("target_hash", "")
spec_events.delete_row(contract_id, sid, target)
applied_ops.append(op)
except Exception:
summary["unresolved"] = summary.get("unresolved", 0) + 1
summary = spec_events.apply_ops(
contract_id, sid, s["document_id"], ops, prompt_id, result
)
applied_ops = ops
except Exception as e:
summary = {"added": 0, "updated": 0, "deleted": 0, "unresolved": len(ops)}
applied_ops = []
yield {
"type": "extract_error",
"supplement_id": sid,
"filename": filename,
"error": str(e),
}
# Arithmetic check
check_arithmetic(contract_id)