auto: 2026-09-17 16:45 (ESD_LAPTOP)

This commit is contained in:
2026-09-17 16:45:50 +09:00
parent c044726d41
commit 2ee6a7ed88
2 changed files with 36 additions and 8 deletions
+10 -4
View File
@@ -148,6 +148,8 @@ def notice(kind: str) -> list[str]:
#: ⚠ 「임도가 쓰는 것」 같은 쓰임 가름은 잣대가 아직 없어 안 냄(지어내지 않음).
FILTER_KEYS = ("division", "axis_role")
ALL = ""
#: 값을 안 보냈을 때 거는 값 — 총칙 줄은 기본 감춤 · 「전부」를 고르면 보임(2026-09-17 브레인)
DEFAULTS = {"axis_role": "work_item"}
def _facets(kind: str) -> dict[str, dict[str, str]]:
@@ -166,7 +168,7 @@ def _role_names() -> dict[str, str]:
def filters(kind: str, rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
"""거르기 상자 — 값이 둘 이상 갈리는 가름만 · 기본은 「전부」(안 거름)."""
"""거르기 상자 — 값이 둘 이상 갈리는 가름만 · 기본은 `DEFAULTS`(그 값이 표에 있을 때) 아니면 「전부」."""
facets = _facets(kind)
labels = {"division": ("부문", {}), "axis_role": ("줄 구실", _role_names())}
out = []
@@ -179,13 +181,14 @@ def filters(kind: str, rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
if len(values) < 2:
continue
label, names = labels[key]
default = DEFAULTS.get(key, ALL)
out.append(
{
"key": key,
"label": label,
"options": [{"value": ALL, "label": "전부", "rows": len(rows)}]
+ [{"value": v, "label": names.get(v, v), "rows": counts[v]} for v in values],
"default": ALL,
"default": default if default in values else ALL,
}
)
return out
@@ -195,8 +198,11 @@ def apply_filters(
kind: str, rows: list[dict[str, Any]], picked: dict[str, str]
) -> list[dict[str, Any]]:
facets = _facets(kind)
for key, value in picked.items():
if key in FILTER_KEYS and value != ALL:
# 안 보낸 가름은 상자 기본값으로 — 상자에 보이는 값과 걸린 값이 같게(찾기 결과가 아니라 표 전체로 정함)
defaults = {f["key"]: f["default"] for f in filters(kind, base_rows(kind))}
for key in FILTER_KEYS:
value = picked.get(key, defaults.get(key, ALL))
if value != ALL:
rows = [r for r in rows if facets.get(r["@id"], {}).get(key) == value]
return rows