Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_1
This commit is contained in:
@@ -24,12 +24,11 @@ DEFAULT_PAGE_SIZE = 50
|
||||
MAX_PAGE_SIZE = 500
|
||||
ROW_KEY = "@key"
|
||||
VALUES_TABLE = "@values"
|
||||
_CODE_HIDDEN = {"@path"} # 낱값 표의 영문 자리 — 이름표에 없을 때만
|
||||
|
||||
# 값 묶음 갈래 — 이름표 `value_groups[].role`(데스크탑 서브) · 낱말이 바뀌면 이 자리만 갈아끼움
|
||||
ROLE_FIELD = "role"
|
||||
# 값 묶음 갈래 — 이름표 `value_groups[].kind`(데스크탑 서브 8fb1952b) · 낱말이 바뀌면 이 자리만 갈아끼움
|
||||
ROLE_FIELD = "kind"
|
||||
SHOWN_ROLE = "value" # 원가·수량에 드는 값 — 낱값 표에 보임
|
||||
HIDDEN_ROLE = "note" # 읽으라고 적은 글 — 안 보임
|
||||
HIDDEN_ROLE = "doc" # 읽으라고 적은 글 — 안 보임
|
||||
# 이름표가 안 가른(또는 모르는 낱말) 마디 — 조용히 빼지도 섞지도 않고 값으로 보이되 드러냄(브레인)
|
||||
UNDECIDED_COLUMN = "@undecided"
|
||||
UNDECIDED = "미판정"
|
||||
@@ -155,6 +154,9 @@ def tree() -> dict[str, Any]:
|
||||
if path is None:
|
||||
continue
|
||||
named = {t["key"]: t.get("name_ko") or "" for t in entry.get("tables") or []}
|
||||
named.update(
|
||||
{k: v.get("name_ko") or "" for k, v in (labels.get("synthetic_tables") or {}).items()}
|
||||
)
|
||||
kind = entry.get("kind") or ""
|
||||
group = groups.setdefault(kind, {"key": kind, "label": kind, "files": []})
|
||||
counts = {tid: len(rows) for tid, rows in tables_of(path).items()}
|
||||
@@ -188,7 +190,9 @@ def rows(
|
||||
table = tables_of(path).get(tid) if path else None
|
||||
if table is None:
|
||||
return None
|
||||
own = next((t for t in entry.get("tables") or [] if t.get("key") == tid), {})
|
||||
own = (labels.get("synthetic_tables") or {}).get(tid) or next(
|
||||
(t for t in entry.get("tables") or [] if t.get("key") == tid), {}
|
||||
) # 낱값 표처럼 API 가 지은 표는 이름표 `synthetic_tables`
|
||||
own_columns = {c.get("key"): c for c in own.get("columns") or []}
|
||||
keys: dict[str, None] = {}
|
||||
for r in table:
|
||||
@@ -214,7 +218,7 @@ def rows(
|
||||
"key": key,
|
||||
"label": named.get("name_ko") or key,
|
||||
"unit": named.get("unit") or "",
|
||||
"hidden": named.get("visible") is False if named else key in _CODE_HIDDEN,
|
||||
"hidden": named.get("visible") is False,
|
||||
}
|
||||
)
|
||||
return {"columns": columns, "rows": hits[start : start + size], "total": len(hits)}
|
||||
|
||||
@@ -170,27 +170,29 @@ def test_찾는_차례와_없는_이름은_영문_key(
|
||||
|
||||
|
||||
def test_낱값은_파일마다_표_하나_설명은_뺌(client: TestClient) -> None:
|
||||
"""브레인 ④ — 표 아닌 마디(값 묶음)도 트리에 `@values` 한 마디로 · 값/설명 가름은 이름표 `role`."""
|
||||
"""브레인 ④ — 표 아닌 마디(값 묶음)도 트리에 `@values` 한 마디로 · 값/설명 가름은 이름표 `kind`."""
|
||||
files = _files(client)
|
||||
rates = files["rates"]["tables"]
|
||||
assert rates[-1]["id"] == "@values"
|
||||
assert rates[-1]["id"] == "@values" and rates[-1]["label"] == "낱값" # 이름표 synthetic_tables
|
||||
values = _rows(client, file="rates", table="@values", size=500)
|
||||
assert values["total"] == rates[-1]["row_count"]
|
||||
by_path = {r["@path"]: r for r in values["rows"]}
|
||||
sanjae = by_path["variables/rate_sanjae"]
|
||||
assert sanjae["@value"] == {"rate_percent": 3.56, "base": "total_labor_cost"}
|
||||
assert sanjae["@name"] == "산재보험료"
|
||||
assert {c["key"]: c["hidden"] for c in values["columns"]} == {
|
||||
"@name": False,
|
||||
"@value": False,
|
||||
"@path": True,
|
||||
assert {c["key"]: (c["label"], c["hidden"]) for c in values["columns"]} == {
|
||||
"@name": ("항목", False),
|
||||
"@value": ("값", False),
|
||||
"@path": ("원문 자리", True),
|
||||
}
|
||||
assert "@values" not in {
|
||||
t["id"] for t in files["work_item_master"]["tables"]
|
||||
} # 방침·집계 = 설명
|
||||
assert "@values" not in {t["id"] for t in files["fx"]["tables"]} # 값 묶음 없음 — 줄이 곧 값
|
||||
for entry in LABELS["files"]: # 보이는 것 = 이름표가 「값」 이라 한 것 그대로
|
||||
want = [g["key"] for g in entry["value_groups"] if g["role"] == "value"]
|
||||
for entry in LABELS[
|
||||
"files"
|
||||
]: # 보이는 것 = 이름표가 「값」 이라 한 것 그대로(수로 박지 않음 — 이름표가 늘어도 맞음)
|
||||
want = [g["key"] for g in entry["value_groups"] if g["kind"] == "value"]
|
||||
got = (
|
||||
_rows(client, file=entry["file_id"], table="@values", size=500)["rows"]
|
||||
if "@values" in {t["id"] for t in files[entry["file_id"]]["tables"]}
|
||||
@@ -209,9 +211,9 @@ def test_이름표가_값_설명을_안_가른_마디는_미판정으로_보임(
|
||||
lagging = [dict(g) for g in entry["value_groups"]]
|
||||
for g in lagging:
|
||||
if g["key"] in ("variables/rate_vat", "variables/rate_goyong/base"):
|
||||
del g["role"] # 이름표가 뒤처짐
|
||||
del g["kind"] # 이름표가 뒤처짐
|
||||
elif g["key"] == "variables/rate_care":
|
||||
g["role"] = "formula" # 코드가 모르는 낱말도 미판정
|
||||
g["kind"] = "formula" # 코드가 모르는 낱말도 미판정
|
||||
(tmp_path / "labels_2026-01-01.json").write_text(
|
||||
json.dumps({**LABELS, "files": [{**entry, "value_groups": lagging}]}, ensure_ascii=False),
|
||||
encoding="utf-8",
|
||||
|
||||
Reference in New Issue
Block a user