From b6eab3ed8ff3af49af0249ad8abf1b873b590723 Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 20 Sep 2026 11:25:06 +0800 Subject: [PATCH] Show original field names in biz-state workbook headers. Stop using Chinese display_name for metric sheet columns so headers match the raw field keys. Co-authored-by: Cursor --- netx_api/biz_state/service.py | 2 +- tests/test_batch_workbook_api.py | 21 +++++++++++++++++++++ web/src/pages/network/BizStatePage.tsx | 3 ++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/netx_api/biz_state/service.py b/netx_api/biz_state/service.py index 91199e1..f6355af 100644 --- a/netx_api/biz_state/service.py +++ b/netx_api/biz_state/service.py @@ -742,7 +742,7 @@ def list_batch_metric_rows( columns = [ { "key": f.name, - "header": f.display_name or f.name, + "header": f.name, # strict original field name (no display_name localization) "role": f.role, "is_key": bool(f.is_key), } diff --git a/tests/test_batch_workbook_api.py b/tests/test_batch_workbook_api.py index e62ce6e..d2f9734 100644 --- a/tests/test_batch_workbook_api.py +++ b/tests/test_batch_workbook_api.py @@ -77,6 +77,27 @@ class BatchWorkbookApiTests(unittest.TestCase): list_batch_metric_rows(db, "b1", "commands") self.assertEqual(ctx.exception.status_code, 400) + def test_metric_columns_use_original_field_names(self) -> None: + batch = BizStateBatch(id="b1", task_id="t1", status="ok") + db = MagicMock() + db.get.return_value = batch + q = MagicMock() + q.filter.return_value = q + q.count.return_value = 0 + q.order_by.return_value.offset.return_value.limit.return_value.all.return_value = [] + db.query.return_value = q + + out = list_batch_metric_rows(db, "b1", "interface_detail", page=1, page_size=10) + self.assertTrue(out["columns"]) + for col in out["columns"]: + self.assertEqual(col["key"], col["header"]) + # Must not surface Chinese display_name as header + self.assertNotIn("接口", col["header"]) + self.assertNotIn("描述", col["header"]) + keys = {c["key"] for c in out["columns"]} + self.assertIn("interface", keys) + self.assertIn("description", keys) + if __name__ == "__main__": unittest.main() diff --git a/web/src/pages/network/BizStatePage.tsx b/web/src/pages/network/BizStatePage.tsx index 8e9739f..169c685 100644 --- a/web/src/pages/network/BizStatePage.tsx +++ b/web/src/pages/network/BizStatePage.tsx @@ -422,7 +422,8 @@ export function BizStatePage() { setSheetTotal(Number(res.total || 0)); const cols = (res.columns || []).map((c) => ({ key: c.key, - header: c.header || c.key, + // Always show original field key; never localized display_name. + header: c.key || c.header || "", })); setSheetColumns(cols.length ? cols : columnsFromRows(res.items || [])); } catch (e) {