fix(flywheel): 补全项目名解析——project_profiles prof- 关联 + 路径末段提取
之前 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 等)清理为目录名。
This commit is contained in:
parent
d41e0f1707
commit
b13dc83b90
@ -365,11 +365,21 @@ pub fn get_all_commit_health() -> Result<Vec<CommitHealthWithName>, 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<Vec<CommitHealthWithName>, 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<Vec<CommitHealthWithName>, 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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user