調整 AI review 以單一 Review 發布統計與 comments #28

Merged
jiantw83 merged 17 commits from ai-review-resolve/20260622100149 into develop 2026-06-22 10:31:46 +00:00
2 changed files with 11 additions and 14 deletions
Showing only changes of commit 71c9b40c0b - Show all commits
+7 -6
View File
@@ -62,15 +62,16 @@ function countBy(findings, predicate) {
function buildReviewSummary(findings, commentable) { function buildReviewSummary(findings, commentable) {
const unplacedCount = findings.length - commentable.length; const unplacedCount = findings.length - commentable.length;
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 [ return [
'## AI Code Review 統計', '## AI Code Review 統計',
'', '',
`總問題:${findings.length}`, '| 統計 | 統計 | 統計 |',
`可標註檔案與行數:${commentable.length}`, '| --- | --- | --- |',
`無法標註檔案與行數${unplacedCount}`, `| **總問題**<br>${findings.length} 筆 | **可標註檔案與行數**<br>${commentable.length} 筆 | **無法標註檔案與行數**<br>${unplacedCount} |`,
`嚴重:${countBy(findings, f => f.level === 'critical')}`, `| **🔴 嚴重**<br>${criticalCount} 筆 | **🟡 警告**<br>${warningCount} 筆 | **🔵 建議**<br>${infoCount} |`,
`警告:${countBy(findings, f => f.level === 'warning')}`,
`建議:${countBy(findings, f => f.level === 'info')}`,
].join('\n'); ].join('\n');
} }
+4 -8
View File
@@ -200,11 +200,9 @@ describe('postFindingsReview', () => {
}); });
assert.equal(reviewCalls.length, 1); assert.equal(reviewCalls.length, 1);
assert.match(reviewCalls[0].body, /總問題:3 筆/); assert.match(reviewCalls[0].body, /\| 統計 \| 統計 \| 統計 \|/);
assert.match(reviewCalls[0].body, /可標註檔案與行數:3 筆/); assert.match(reviewCalls[0].body, /\| \*\*總問題\*\*<br>3 筆 \| \*\*可標註檔案與行數\*\*<br>3 筆 \| \*\*無法標註檔案與行數\*\*<br>0 筆 \|/);
assert.match(reviewCalls[0].body, /嚴重:1 筆/); assert.match(reviewCalls[0].body, /\| \*\*🔴 嚴重\*\*<br>1 筆 \| \*\*🟡 警告\*\*<br>1 筆 \| \*\*🔵 建議\*\*<br>1 筆 \|/);
assert.match(reviewCalls[0].body, /警告:1 筆/);
assert.match(reviewCalls[0].body, /建議:1 筆/);
assert.deepEqual( assert.deepEqual(
reviewCalls[0].comments.map(c => c.path), reviewCalls[0].comments.map(c => c.path),
['app/a.js', 'app/b.js', 'app/c.js'], ['app/a.js', 'app/b.js', 'app/c.js'],
@@ -229,9 +227,7 @@ describe('postFindingsReview', () => {
}); });
assert.equal(reviewCalls.length, 1); assert.equal(reviewCalls.length, 1);
assert.match(reviewCalls[0].body, /總問題:2 筆/); assert.match(reviewCalls[0].body, /\| \*\*總問題\*\*<br>2 筆 \| \*\*可標註檔案與行數\*\*<br>1 筆 \| \*\*無法標註檔案與行數\*\*<br>1 筆 \|/);
assert.match(reviewCalls[0].body, /可標註檔案與行數:1 筆/);
assert.match(reviewCalls[0].body, /無法標註檔案與行數:1 筆/);
assert.equal(reviewCalls[0].comments.length, 1); assert.equal(reviewCalls[0].comments.length, 1);
assert.equal(reviewCalls[0].comments[0].path, 'app/b.js'); assert.equal(reviewCalls[0].comments[0].path, 'app/b.js');
}); });