From fe15b117336ad218f613244504585c421c417a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B8=85?= Date: Wed, 2 Sep 2026 17:10:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=90=8E=E5=8F=B0=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ocr_dashboard_service.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ocr_dashboard_service.py b/ocr_dashboard_service.py index ff036c3..6347acb 100644 --- a/ocr_dashboard_service.py +++ b/ocr_dashboard_service.py @@ -83,6 +83,21 @@ def _overlay_acceptance_questions(data: dict[str, Any], batch_key: str) -> dict[ return data if not keywords: return data + configured_codes: dict[str, str] = {} + if Config.EVIDENCE_ADMIN_BASE_URL: + try: + response = SESSION.get( + f"{Config.EVIDENCE_ADMIN_BASE_URL}/api/options", + timeout=min(Config.CRAWLER_TIMEOUT_SECONDS, 10), + ) + response.raise_for_status() + scopes = (response.json().get("data") or {}).get("scopes") or [] + configured_codes = { + str(row.get("search_keyword") or ""): str(row.get("question_code") or "") + for row in scopes if str(row.get("batch_key") or "") == normalized_key + } + except (requests.RequestException, ValueError): + configured_codes = {} current = { str(item.get("search_keyword") or ""): item for item in data.get("questions", []) @@ -91,7 +106,8 @@ def _overlay_acceptance_questions(data: dict[str, Any], batch_key: str) -> dict[ for index, keyword in enumerate(keywords): item = dict(current.get(keyword, {})) item.update({ - "question_code": item.get("question_code") or "X" + hashlib.sha256(keyword.encode()).hexdigest()[:15], + "question_code": item.get("question_code") or configured_codes.get(keyword) + or "X" + hashlib.sha256(keyword.encode()).hexdigest()[:15], "search_keyword": keyword, "question_direction": item.get("question_direction") or task["name"], "display_order": index + 1,