使用后台正式问题编号
This commit is contained in:
@@ -83,6 +83,21 @@ def _overlay_acceptance_questions(data: dict[str, Any], batch_key: str) -> dict[
|
|||||||
return data
|
return data
|
||||||
if not keywords:
|
if not keywords:
|
||||||
return data
|
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 = {
|
current = {
|
||||||
str(item.get("search_keyword") or ""): item
|
str(item.get("search_keyword") or ""): item
|
||||||
for item in data.get("questions", [])
|
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):
|
for index, keyword in enumerate(keywords):
|
||||||
item = dict(current.get(keyword, {}))
|
item = dict(current.get(keyword, {}))
|
||||||
item.update({
|
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,
|
"search_keyword": keyword,
|
||||||
"question_direction": item.get("question_direction") or task["name"],
|
"question_direction": item.get("question_direction") or task["name"],
|
||||||
"display_order": index + 1,
|
"display_order": index + 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user