Commit 735a46e9 authored by Data Governance Dev's avatar Data Governance Dev

fix(web): 修复概览/表注释展示为空问题,重整空字段与冗余字段 tab

后端
- models.py: OverviewStats 补充 mid_empty_fields / standards_applied 字段,
  避免被 routes.py 的字段过滤机制误删
- orchestrator.py: _build_overview 修正 nested overview_meta 取值(三层嵌套,
  之前一直兜底到 0 → 表/字段总数显示 0)
- step4_empty_fields.py: 修复 table_comment 始终为空(之前从列级 row 取
  table_comment,应从 table_summary 取),新增 per_table.total_fields 与
  field_record 用同一份 table_comment_map

前端 (index.html / style.css)
- 隐藏历史记录入口(保留后端接口,便于以后恢复)
- 移除「中空字段」KPI 卡片(位于中间不符合浏览习惯)
- 大范围空字段 tab:
  * 字段明细(平铺:等级/表名/表注释/字段名/字段注释/类型/空值数/空值率)
    上移到主视图位置
  * 按表统计下移为辅助视图,表名+表注释合并到一列避免错位
- 冗余字段 tab:把 prop 改成与后端实际数据一致的
  field/table_count/classification/reasoning/recommendation/source,并
  给 llm_failed / true_redundancy / suspicious / common_business /
  common_base 各加色 tag 显著标识
- 修复"\"LLM 失败\""导致的 template compile 错误引发的白屏
  (HTML 属性里 \ 不会被当 JS 转义,把 " 换成「 」即可)
- .app-main 宽度 1400 → 1800px,table 更舒展
parent d442e8fb
......@@ -99,9 +99,11 @@ class OverviewStats(BaseModel):
total_tables: int = 0
total_fields: int = 0
high_empty_fields: int = 0
mid_empty_fields: int = 0
missing_comments: int = 0
length_issues: int = 0
standard_violations: int = 0
standards_applied: int = 0
merge_candidates: int = 0
redundancy_fields: int = 0
executed_at: Optional[datetime] = None
......
......@@ -345,7 +345,11 @@ def _generate_reports(run_dir: Path, sections: dict, overview: dict,
# ── Overview 构造 ──
def _build_overview(sections: dict, cfg: DBConfig) -> dict:
"""从各 section 汇总概览数据"""
overview_meta = sections.get("overview_meta", {})
# step1 返回的 data 嵌套了三层:sections["overview_meta"] =
# {"data_dictionary": [...], "table_summary": [...], "overview_meta": {total_tables, total_fields, ...}}
# 统计字段在最内层 overview_meta 里
overview_meta_root = sections.get("overview_meta", {})
overview_meta = overview_meta_root.get("overview_meta", overview_meta_root) if isinstance(overview_meta_root, dict) else {}
empty = sections.get("empty_fields", {}).get("summary", {})
missing = sections.get("missing_comments", {}).get("summary", {})
length = sections.get("length_issues", {}).get("summary", {})
......
......@@ -46,6 +46,21 @@ def run_step4(cfg: DBConfig, log: Callable | None = None,
for row in columns:
by_table[row["table_name"]].append(row)
# 表级注释来自 table_summary(INFORMATION_SCHEMA.TABLES),
# 列级 row(COLUMNS)没有 table_comment 字段
table_comment_map: dict[str, str] = {}
for t in table_summary:
name = t.get("table_name") or t.get("TABLE_NAME")
if not name:
continue
comment = (
t.get("table_comment")
or t.get("TABLE_COMMENT")
or ""
)
if comment:
table_comment_map[name] = comment
loader = get_sql_loader()
high_count = 0
mid_count = 0
......@@ -118,7 +133,7 @@ def run_step4(cfg: DBConfig, log: Callable | None = None,
empty_rate = empty_count / row_count if row_count else 0
field_record = {
"table_name": table,
"table_comment": col.get("table_comment", ""),
"table_comment": table_comment_map.get(table, ""),
"column_name": col["column_name"],
"data_type": col["data_type"],
"column_type": col["column_type"],
......@@ -140,10 +155,12 @@ def run_step4(cfg: DBConfig, log: Callable | None = None,
if high_in_table or mid_in_table:
tables_with_issues.add(table)
total_fields_in_table = len(by_table[table])
per_table.append({
"table_name": table,
"table_comment": by_table[table][0].get("table_comment", ""),
"table_comment": table_comment_map.get(table, ""),
"total_rows": row_count,
"total_fields": total_fields_in_table,
"high_empty_fields": high_in_table,
"mid_empty_fields": mid_in_table,
"high_count": len(high_in_table),
......
This diff is collapsed.
......@@ -67,7 +67,8 @@ body {
}
.app-main {
max-width: 1400px;
width: 100%;
max-width: 1800px;
margin: 0 auto;
padding: 20px;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment