From b13dc83b905f7cd6c8b1d28f83a5a345faf1a838 Mon Sep 17 00:00:00 2001 From: lanrtop Date: Mon, 29 Jun 2026 21:30:43 +0900 Subject: [PATCH] =?UTF-8?q?fix(flywheel):=20=E8=A1=A5=E5=85=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=90=8D=E8=A7=A3=E6=9E=90=E2=80=94=E2=80=94project?= =?UTF-8?q?=5Fprofiles=20prof-=20=E5=85=B3=E8=81=94=20+=20=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E6=9C=AB=E6=AE=B5=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 get_all_commit_health 只有两条名称解析路径,导致: 1. 孤儿 UUID(blueprint_buffs 记录已删但 commit_metrics 数据保留)显示为 UUID 字符串 2. blueprint_buffs 有路径但 projects 表无对应项目时显示完整路径 本次新增第三条路径:LEFT JOIN project_profiles ON id = 'prof-' + UUID, 可解析 makemd-2026、enterprise-system、beast-mode、my-docs、yljt-index 等 10 个孤儿 UUID; Rust 端对最终名称进行路径末段提取,将剩余路径字符串(react-phone-apps、ReadBorne 等)清理为目录名。 --- src-tauri/src/commands/commit_metrics.rs | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands/commit_metrics.rs b/src-tauri/src/commands/commit_metrics.rs index cc16689..57e59c5 100644 --- a/src-tauri/src/commands/commit_metrics.rs +++ b/src-tauri/src/commands/commit_metrics.rs @@ -365,11 +365,21 @@ pub fn get_all_commit_health() -> Result, String> { let conn = crate::db::pool().get().map_err(|e| e.to_string())?; let round3 = |v: f64| (v * 1000.0).round() / 1000.0; - // 聚合各 project_id 的指标,并通过两条路径解析名称 + // 聚合各 project_id 的指标,四条路径解析名称: + // 1) projects 直接匹配(名称字符串 id) + // 2) blueprint_buffs + projects 路径关联 + // 3) project_profiles "prof-UUID" 格式(孤儿 UUID 的名称来源) + // 4) blueprint_buffs.project_path(后处理提取末段目录名) let mut stmt = conn.prepare( "SELECT cm.project_id, - COALESCE(p_direct.name, p_via_buff.name, bb.project_path, cm.project_id) AS name, + COALESCE( + p_direct.name, + p_via_buff.name, + pp_prof.name, + bb.project_path, + cm.project_id + ) AS name, COUNT(*) AS total, SUM(CASE WHEN cm.commit_type IS NOT NULL THEN 1 ELSE 0 END) AS conventional, SUM(CASE WHEN cm.is_rework=1 AND cm.is_ci_auto=0 THEN 1 ELSE 0 END) AS rework @@ -379,6 +389,7 @@ pub fn get_all_commit_health() -> Result, String> { LEFT JOIN projects p_via_buff ON p_via_buff.win_path = bb.project_path OR p_via_buff.wsl_path = bb.project_path + LEFT JOIN project_profiles pp_prof ON pp_prof.id = ('prof-' || cm.project_id) GROUP BY cm.project_id ORDER BY total DESC", ).map_err(|e| e.to_string())?; @@ -422,11 +433,20 @@ pub fn get_all_commit_health() -> Result, String> { .filter_map(|r| r.ok()) .collect(); + // 如果 name 解析为路径(含 / 或 \),取末段目录名 + let display_name = if name.contains('/') || name.contains('\\') { + name.split(['/', '\\']).filter(|s| !s.is_empty()).last() + .unwrap_or(&name) + .to_string() + } else { + name + }; + result.push(CommitHealthWithName { conventional_rate: round3(if total > 0 { conventional as f64 / total as f64 } else { 0.0 }), rework_rate: round3(if conventional > 0 { rework as f64 / conventional as f64 } else { 0.0 }), project_id: pid, - project_name: name, + project_name: display_name, total_commits: total, conventional_commits: conventional, rework_commits: rework,