feat(ai-review 統計): 將統計改為新舊問題分列
This commit is contained in:
+22
-6
@@ -60,16 +60,28 @@ function countBy(findings, predicate) {
|
||||
return findings.filter(predicate).length;
|
||||
}
|
||||
|
||||
function newFindingsOnly(findings) {
|
||||
return findings.filter(f => f.is_new !== false);
|
||||
}
|
||||
|
||||
export function formatFindingsStats(findings) {
|
||||
const oldFindings = findings.filter(f => f.is_new === false);
|
||||
const newFindings = newFindingsOnly(findings);
|
||||
const row = (label, items) => `| ${label} | ${countBy(items, f => f.level === 'critical')} 筆 | ${countBy(items, f => f.level === 'warning')} 筆 | ${countBy(items, f => f.level === 'info')} 筆 |`;
|
||||
|
||||
return [
|
||||
'| 類型 | 🔴 嚴重 | 🟡 警告 | 🔵 建議 |',
|
||||
'| --- | --- | --- | --- |',
|
||||
row('舊問題', oldFindings),
|
||||
row('新問題', newFindings),
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function buildReviewSummary(findings) {
|
||||
const criticalCount = countBy(findings, f => f.level === 'critical');
|
||||
const warningCount = countBy(findings, f => f.level === 'warning');
|
||||
const infoCount = countBy(findings, f => f.level === 'info');
|
||||
return [
|
||||
'## AI Code Review 統計',
|
||||
'',
|
||||
'| 🔴 嚴重 | 🟡 警告 | 🔵 建議 |',
|
||||
'| --- | --- | --- |',
|
||||
`| ${criticalCount} 筆 | ${warningCount} 筆 | ${infoCount} 筆 |`,
|
||||
formatFindingsStats(findings),
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
@@ -99,6 +111,10 @@ export async function postFindingsReview(findings, deps = {}) {
|
||||
const body = buildReviewSummary(summaryFindings);
|
||||
await postReview({ body, comments });
|
||||
ok(`review 發布: summary=${summaryFindings.length} total=${sortedComments.length} commentable=${comments.length}`);
|
||||
line('review summary 統計:');
|
||||
for (const row of formatFindingsStats(summaryFindings).split('\n')) line(row);
|
||||
line('review comments 統計:');
|
||||
for (const row of formatFindingsStats(sortedComments).split('\n')) line(row);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user