feat(ai-review 統計): 統計表改為四欄(含無法標示)並分新舊兩列
This commit is contained in:
+9
-6
@@ -64,24 +64,27 @@ function newFindingsOnly(findings) {
|
|||||||
return findings.filter(f => f.is_new !== false);
|
return findings.filter(f => f.is_new !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 等級無法歸入 critical/warning/info(例如缺漏或無法辨識)時,歸入「無法標示」
|
||||||
|
const isUnclassified = f => !LEVEL_ORDER.includes(f.level);
|
||||||
|
|
||||||
export function formatFindingsStats(findings) {
|
export function formatFindingsStats(findings) {
|
||||||
const oldFindings = findings.filter(f => f.is_new === false);
|
const oldFindings = findings.filter(f => f.is_new === false);
|
||||||
const newFindings = newFindingsOnly(findings);
|
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')} 筆 |`;
|
const row = (label, items) => `| ${label} | ${countBy(items, f => f.level === 'critical')} 筆 | ${countBy(items, f => f.level === 'warning')} 筆 | ${countBy(items, f => f.level === 'info')} 筆 | ${countBy(items, isUnclassified)} 筆 |`;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'| 類型 | 🔴 嚴重 | 🟡 警告 | 🔵 建議 |',
|
'| 類型 | 🔴 嚴重 | 🟡 警告 | 🔵 建議 | ⚪ 無法標示 |',
|
||||||
'| --- | --- | --- | --- |',
|
'| --- | --- | --- | --- | --- |',
|
||||||
row('舊問題', oldFindings),
|
|
||||||
row('新問題', newFindings),
|
row('新問題', newFindings),
|
||||||
|
row('舊問題', oldFindings),
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatFindingsStatsLine(findings) {
|
export function formatFindingsStatsLine(findings) {
|
||||||
const oldFindings = findings.filter(f => f.is_new === false);
|
const oldFindings = findings.filter(f => f.is_new === false);
|
||||||
const newFindings = newFindingsOnly(findings);
|
const newFindings = newFindingsOnly(findings);
|
||||||
const row = items => `嚴重${countBy(items, f => f.level === 'critical')} / 警告${countBy(items, f => f.level === 'warning')} / 建議${countBy(items, f => f.level === 'info')}`;
|
const row = items => `嚴重${countBy(items, f => f.level === 'critical')} / 警告${countBy(items, f => f.level === 'warning')} / 建議${countBy(items, f => f.level === 'info')} / 無法標示${countBy(items, isUnclassified)}`;
|
||||||
return `舊: ${row(oldFindings)};新: ${row(newFindings)}`;
|
return `新: ${row(newFindings)};舊: ${row(oldFindings)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildReviewSummary(findings, usageSection = '') {
|
function buildReviewSummary(findings, usageSection = '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user