From 2b971c3c905206c1cba907f631afc2f738c8a226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 28 Jun 2026 10:04:49 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20date=5Fstart=20=D0=B2=20name=5Fhash=20?= =?UTF-8?q?=E2=80=94=20=D1=80=D0=B0=D0=B7=D0=BB=D0=B8=D1=87=D0=B0=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=BF=D0=B5=D1=80=D0=B8=D0=BE=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/db/spec_events.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deploy/db/spec_events.py b/deploy/db/spec_events.py index e23081e..e99d052 100644 --- a/deploy/db/spec_events.py +++ b/deploy/db/spec_events.py @@ -45,7 +45,7 @@ def apply_ops(contract_id, supplement_id, document_id, ops, prompt_id, raw_llm_r if action == "ADD": nr = op.get("new_row", {}) name = nr.get("name", "") - name_hash = _hash(name) + name_hash = _hash(name, nr.get("date_start")) execute( """INSERT INTO spec_events (contract_id, supplement_id, seq, action, target_hash, new_values, comment, status, prompt_version, source_document_id, raw_llm_response) @@ -116,9 +116,13 @@ def apply_ops(contract_id, supplement_id, document_id, ops, prompt_id, raw_llm_r return {"added": added, "updated": updated, "deleted": deleted} -def _hash(name): +def _hash(name, date_start=None): + """Нормализованный хеш услуги. Включает date_start чтобы различать периоды.""" import hashlib - return hashlib.sha256(name.strip().lower().encode()).hexdigest()[:16] + key = name.strip().lower() + if date_start: + key += "|" + str(date_start) + return hashlib.sha256(key.encode()).hexdigest()[:16] def _upsert_spec_current(contract_id, name_hash, row):