From a8d635f2cc5f76ba68c80c342b9a995c8ce26b78 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 17 Sep 2026 17:43:14 +0900 Subject: [PATCH] =?UTF-8?q?feat(z01):=20=EC=B0=BE=EA=B8=B0=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=AC=BC=EA=B2=B0=ED=91=9C=C2=B7=EA=B0=80=EC=9A=B4?= =?UTF-8?q?=EB=8E=83=EC=A0=90=C2=B7=EB=9D=84=EC=96=B4=EC=93=B0=EA=B8=B0?= =?UTF-8?q?=EB=A5=BC=20=EA=B0=99=EA=B2=8C=20=EB=B4=84=20=E2=80=94=20?= =?UTF-8?q?=EC=9B=90=EB=AC=B8=EC=9D=B4=20=E2=88=BC=C2=B7=EF=BD=9E=20?= =?UTF-8?q?=EB=A5=BC=20=EC=84=9E=EC=96=B4=20=EC=8D=A8=20=E3=80=8C~?= =?UTF-8?q?=E3=80=8D=EB=A1=9C=20=EC=B9=98=EB=A9=B4=200=EC=A4=84=EC=9D=B4?= =?UTF-8?q?=EB=8D=98=20=EA=B2=83=20=C2=B7=20=EC=B0=BE=EA=B8=B0=EC=97=90?= =?UTF-8?q?=EB=A7=8C=20=EC=93=B0=EA=B3=A0=20=EC=97=B4=EC=87=A0=C2=B7?= =?UTF-8?q?=EC=B9=B8=20=EA=B0=92=EC=9D=80=20=EC=9B=90=EB=AC=B8=20=EA=B7=B8?= =?UTF-8?q?=EB=8C=80=EB=A1=9C(=EA=B0=88=EB=9E=98=20=EC=97=B4=EC=87=A0=20?= =?UTF-8?q?=ED=9D=94=EB=93=A4=EB=A6=BC=20=EB=B0=A9=EC=A7=80=20=C2=B7=20?= =?UTF-8?q?=EB=B8=8C=EB=A0=88=EC=9D=B8=20=C2=B7=20=EC=84=9C=EB=B8=8C=20?= =?UTF-8?q?=ED=9B=91=EA=B8=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01BW6Jdsh18WPtYUR6THZJqn --- Z01_MasterData/Z01_MasterData_BasePrices.py | 16 ++++++++++++++-- resources/tester/test_z01_work_items.py | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Z01_MasterData/Z01_MasterData_BasePrices.py b/Z01_MasterData/Z01_MasterData_BasePrices.py index 0c845447..8eb68f64 100644 --- a/Z01_MasterData/Z01_MasterData_BasePrices.py +++ b/Z01_MasterData/Z01_MasterData_BasePrices.py @@ -517,6 +517,18 @@ def public(row: dict[str, Any]) -> dict[str, Any]: return {k: v for k, v in row.items() if k not in ("@source", "@axis")} +#: 찾기만 같게 보는 글자 — 원문이 물결표·가운뎃점을 여러 벌로 씀(∼ 26 · ~ 8 · ․ · ㆍ) · 자간 공백(「굴 삭 기」). +#: ⚠ **찾기에만** 씀 — 열쇠·칸 값은 원문 그대로(손질하면 갈래 열쇠가 갈림 · 브레인 2026-09-17). +_SEARCH_SAME = str.maketrans( + {"∼": "~", "~": "~", "〜": "~", "․": "·", "ㆍ": "·", "・": "·", "‧": "·"} +) + + +def fold(text: str) -> str: + """찾기 비교용 — 소문자 · 물결표·가운뎃점 한 벌 · 공백 없앰.""" + return "".join(str(text or "").lower().translate(_SEARCH_SAME).split()) + + def table( kind: str, page: int = 1, @@ -528,12 +540,12 @@ def table( ) -> dict[str, Any]: all_rows = rows(kind) columns = _columns(kind, all_rows) - needle = q.strip().lower() + needle = fold(q) hits = ( [ r for r in all_rows - if needle in json.dumps(public(r), ensure_ascii=False, default=str).lower() + if needle in fold(json.dumps(public(r), ensure_ascii=False, default=str)) ] if needle else all_rows diff --git a/resources/tester/test_z01_work_items.py b/resources/tester/test_z01_work_items.py index b34309ca..093fbbb7 100644 --- a/resources/tester/test_z01_work_items.py +++ b/resources/tester/test_z01_work_items.py @@ -38,7 +38,9 @@ def _get(client: TestClient, kind: str, **params) -> dict: def test_산림_평평한_잎_목록과_계산_규칙(client: TestClient) -> None: listed = client.get("/api/master-data/base-prices").json()["kinds"] forest = next(i for i in listed if i["kind"] == "work_item_forest") - assert forest["group"] == "work_item" and forest["rows"] == 620 # 갈래마다 한 줄 · 헛단위 7줄 뺌(2026-09-17) + assert ( + forest["group"] == "work_item" and forest["rows"] == 620 + ) # 갈래마다 한 줄 · 헛단위 7줄 뺌(2026-09-17) # 상자 이름은 이름표 것 — 영문 키(work_item)로 뜨던 자리(2026-09-17 브레인 ①) assert {i["group"]: i["group_label"] for i in listed} == { "base_price": "기초단가", @@ -240,3 +242,18 @@ def test_총칙_줄은_기본_감춤_전부를_고르면_보임(client: TestClie _get(client, kind, size=1, axis_role="general_provision")["total"] == (counts["general_provision"]) ) + + +def test_찾기는_물결표_가운뎃점_띄어쓰기를_같게_봄(client: TestClient) -> None: + """원문이 물결표를 둘(∼·~)로 쓰고 자간 공백이 들쭉날쭉 — 사람이 친 「~」·붙여 쓴 이름으로도 찾힘. + ⚠ 찾기만 — 줄 값·열쇠는 원문 그대로(서브 훑기 · 브레인 2026-09-17).""" + wavy = _get(client, "work_item_forest", size=50, q="2.1∼2.5")["total"] + assert wavy >= 1 + assert _get(client, "work_item_forest", size=50, q="2.1~2.5")["total"] == wavy + assert _get(client, "work_item_forest", size=50, q="2.1~2.5")["total"] == wavy + rows = _get(client, "work_item_forest", size=50, q="2.1~2.5")["rows"] + assert all("~" not in r["@id"] for r in rows) # 열쇠는 손질 안 함 + spaced = _get(client, "work_item_forest", size=50, q="토사 깍기", axis_role="")["total"] + assert ( + spaced == _get(client, "work_item_forest", size=50, q="토사깍기", axis_role="")["total"] > 0 + )