feat: сортировка допников по doc_date

This commit is contained in:
2026-06-28 10:04:11 +04:00
parent 8eae0eec64
commit 19e602fd62
+3
View File
@@ -17,6 +17,9 @@ def run_pipeline(contract_id, order_ids, sse_send, build_prompt_fn):
order_list = [x.strip() for x in order_ids.split(",") if x.strip()]
order_map = {oid: i for i, oid in enumerate(order_list)}
supps.sort(key=lambda s: order_map.get(s["id"], 999999))
else:
# Sort by doc_date (from classification), fallback to created_at
supps.sort(key=lambda s: (s.get("doc_date") or "9999-99-99", s.get("created_at", "")))
if not supps:
sse_send({"type": "error", "message": "Нет распарсенных файлов"})