mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-23 02:12:02 +00:00
目录修改提案落在已驳回的项上时,改前写出被驳回的原值:plan_patch 交回的 before 带上驳回的值、before_status 写 rejected(只改给人看的信息,算改后、算状态照旧按没有这一项,保存时照旧换成人工确认的新值);助手流的提案卡片、表助手的提案卡片和待保存的修改写「已驳回:<原值>」,和导入预览「目标里这一项已经驳回」一致;check-catalog-loop、check-stream 补对应检查
This commit is contained in:
@@ -878,7 +878,8 @@ class PatchChange:
|
||||
"""提案里的一项,核对过的。
|
||||
|
||||
- path:规范化后的路径(新增关系写成 relations.<编号>);
|
||||
- before / before_status:当前目录里这一项的值和状态(被驳回的和没有的都算没有,为 None);
|
||||
- before / before_status:当前目录里这一项的值和状态,没有这一项为 None。被驳回的照样给出原值、状态写 rejected
|
||||
(同导入预览「目标里这一项已经驳回」):只是给人看的,算改后、算 state 都按没有这一项,保存时换成人工确认的新值;
|
||||
- after:保存后的值(码值是补充后的完整对照);value:要交回保存的原样取值(码值只有补充的那几个,
|
||||
409 之后在最新的目录上重新补);
|
||||
- state:change 值有变化;confirm 值相同、但还不是已确认(保存即确认);same 已经是这个值且已确认。
|
||||
@@ -1014,6 +1015,8 @@ def plan_patch(notes: Mapping[str, Any] | None, changes: Any, *, table: str,
|
||||
没有这个码时加进去,不会把已有的含义抹掉(_merge_codes)。
|
||||
- 关联关系不抹掉测量结果:覆盖率沿用目录里的,基数没写时沿用或推算(_relation_after)。两端、基数、覆盖率都和
|
||||
目录里一样时只是确认,来源不变。
|
||||
- 被驳回的项算没有:码值不在驳回的码值上补,和驳回的值一样也是 change(保存时换成人工确认的新值)。改前照样写出
|
||||
驳回的原值、before_status 为 rejected,不然界面上只看到「未填写」,看不出原来有一个被驳回的值。
|
||||
- 看起来像计算公式的文字不收(_FORMULA):公式进口径卡。
|
||||
- 同一个路径出现两次只认第一次。
|
||||
"""
|
||||
@@ -1094,8 +1097,10 @@ def plan_patch(notes: Mapping[str, Any] | None, changes: Any, *, table: str,
|
||||
state = "same" if live.get("status") == "confirmed" else "confirm"
|
||||
else:
|
||||
state = "change"
|
||||
out.append(PatchChange(path=norm, before=copy.deepcopy(before),
|
||||
before_status=live.get("status") if live is not None else None,
|
||||
# 改前给人看:被驳回的也写出原值(上面算改后、算 state 照旧按没有这一项)
|
||||
shown = live if live is not None else prev
|
||||
out.append(PatchChange(path=norm, before=copy.deepcopy(_value_of(key, shown)) if shown is not None else None,
|
||||
before_status=shown.get("status") if shown is not None else None,
|
||||
after=after, value=value, reason=reason, state=state, note=note))
|
||||
return PatchPlan(out, problems)
|
||||
|
||||
|
||||
@@ -204,6 +204,36 @@ async def test_saving_keeps_the_reason_as_the_note(scenic_db):
|
||||
assert catalog.validate_notes(out) == []
|
||||
|
||||
|
||||
async def test_rejected_items_show_their_value_before(scenic_db):
|
||||
"""提案落在已驳回的项上:改前带上被驳回的原值、状态写已驳回(同导入预览「目标里这一项已经驳回」)。只改预览给出的
|
||||
信息,保存的规矩不变:照旧换成人工确认的新值;码值不在驳回的码值上补;和驳回的值一样的也不算「值不变」,照样存成
|
||||
人工确认。"""
|
||||
tables = (await _schema(scenic_db))["tables"]
|
||||
rejected = scenic_notes.notes("rejected")["visits"]
|
||||
rel_value = {"columns": ["park_id"], "to_table": "parks", "to_columns": ["id"], "cardinality": "many_to_one"}
|
||||
changes = [
|
||||
{"path": "columns.visitor_count.measure", "value": "stock"},
|
||||
{"path": "columns.status.codes", "value": {"9": "作废"}},
|
||||
{"path": "valid_filter", "value": "status = 1"}, # 和驳回的值一样
|
||||
{"path": f"relations.{_PARKS}", "value": rel_value}, # 两端、基数都和驳回的那条一样
|
||||
]
|
||||
plan = catalog.plan_patch(rejected, changes, table="visits", tables=tables)
|
||||
assert plan.problems == []
|
||||
measure, codes, valid, rel = plan.changes
|
||||
assert (measure.before, measure.before_status, measure.state) == ("flow", "rejected", "change")
|
||||
assert (codes.before, codes.before_status, codes.state) == ({"1": "有效", "0": "作废"}, "rejected", "change")
|
||||
assert codes.after == {"9": "作废"}, "码值不在驳回的码值上补"
|
||||
assert (valid.before, valid.before_status, valid.state) == ("status = 1", "rejected", "change")
|
||||
assert (rel.before, rel.before_status, rel.state) == ({**rel_value, "coverage": None}, "rejected", "change")
|
||||
assert rel.as_dict()["before_status"] == "rejected" and rel.as_dict()["before"]["to_table"] == "parks"
|
||||
out = catalog.apply_patch(rejected, changes, table="visits", tables=tables)
|
||||
saved = [out["columns"]["visitor_count"]["measure"], out["columns"]["status"]["codes"], out["valid_filter"],
|
||||
next(r for r in out["relations"] if r["id"] == _PARKS)]
|
||||
assert all((item["source"], item["status"]) == ("human", "confirmed") for item in saved)
|
||||
codes = out["columns"]["status"]["codes"]
|
||||
assert codes["value"] == {"9": "作废"} and "complete" not in codes
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 协议
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user