fix(854-1): 기계 창 목록 시간당 메모에 색인 지킴 — 묶음 ②
- `M02_Machine_Hourly._BRIEF` 열쇠 = 색인 주소(`id`) → 키 · 값에 만든 색인을 같이 두고 꺼낼 때 `is` 확인 · 색인이 바뀌면 통째 비움 (옛 색인 주소가 다시 쓰이면 옛 시간당이 나올 수 있던 틈 · `M02_Sangeun_Copy._CACHE` 와 같은 꼴) - 시험 test_854_1 ④ — 색인을 바꾸면 새 가격 · 시간당 · 되돌리면 처음 값 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -235,7 +235,9 @@ def doc_sums(row: dict, logic: dict, index: Any) -> dict | None:
|
||||
return {"ok": True, "합": {k: float(got[k]) for k in (*cm.mf.COST_ITEMS, "계")}}
|
||||
|
||||
|
||||
_BRIEF: dict[tuple, dict] = {}
|
||||
#: {키: (색인, 줄)} — 색인이 바뀌면 비움 · 꺼낼 때 `is` 확인(옛 색인 주소 재사용 · 옛 값 막음 · 854-1)
|
||||
_BRIEF: dict[str, tuple[Any, dict]] = {}
|
||||
_BRIEF_OF: list[Any] = [None]
|
||||
|
||||
|
||||
def brief(keys: list[str]) -> list[dict[str, Any]]:
|
||||
@@ -246,11 +248,15 @@ def brief(keys: list[str]) -> list[dict[str, Any]]:
|
||||
from M02_MasterTemplete.M02_Item_Prices import to_json
|
||||
|
||||
index, mf = store.loaded()[1], cm.mf
|
||||
if len(_BRIEF) > 2000: # ponytail: 통째 비움 · 기계 수(655)의 세 배
|
||||
# ponytail: 통째 비움 · 기계 수(655)의 세 배
|
||||
if _BRIEF_OF[0] is not index or len(_BRIEF) > 2000:
|
||||
_BRIEF.clear()
|
||||
_BRIEF_OF[0] = index
|
||||
out = []
|
||||
for key in keys[:60]:
|
||||
if (got := _BRIEF.get((id(index), key))) is None:
|
||||
hit = _BRIEF.get(key)
|
||||
got = hit[1] if hit and hit[0] is index else None
|
||||
if got is None:
|
||||
try:
|
||||
row = (index.numbers.get("EQ") or {}).get(key) or index.get(key)
|
||||
except mf.FormulaError:
|
||||
@@ -272,7 +278,8 @@ def brief(keys: list[str]) -> list[dict[str, Any]]:
|
||||
)
|
||||
hour = {"ok": True, "로직": logic["키"]}
|
||||
hour |= {k: float(sums[k]) for k in (*cm.mf.COST_ITEMS, "계")}
|
||||
got = _BRIEF[(id(index), key)] = {**head, "값": to_json(row.get("값")), "시간당": hour}
|
||||
got = {**head, "값": to_json(row.get("값")), "시간당": hour}
|
||||
_BRIEF[key] = (index, got)
|
||||
out.append(got)
|
||||
return out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user