@@ -37,23 +37,25 @@ export function createSlackBlocks(summary, dateDisplay, options) {
3737 workflowCount,
3838 } = options ;
3939
40- const relevantItems = summary . filter (
41- item =>
42- item . brokenCount > 0 ||
43- item . flakyCount > 0 ||
44- ( item . latestClassification === 'passed' && ( ( item . historicalBrokenCount ?? 0 ) > 0 || ( item . historicalFlakyCount ?? 0 ) > 0 ) ) ,
45- ) ;
46- const topItems = relevantItems . slice ( 0 , topN ) ;
47- const broken = topItems . filter ( item => item . brokenCount > 0 ) ;
48- const flaky = topItems . filter ( item => item . brokenCount === 0 && item . flakyCount > 0 ) ;
49- const review = topItems . filter (
40+ const maxBroken = Math . min ( topN > 5 ? 5 : Math . floor ( topN / 2 ) , topN ) ;
41+ const maxFlaky = Math . min ( topN > 10 ? 3 : Math . floor ( topN / 3 ) , topN ) ;
42+ const maxReview = Math . min ( topN > 10 ? 2 : 1 , topN ) ;
43+
44+ const brokenItems = summary . filter ( item => item . brokenCount > 0 ) ;
45+ const flakyItems = summary . filter ( item => item . brokenCount === 0 && item . flakyCount > 0 ) ;
46+ const reviewItems = summary . filter (
5047 item =>
5148 item . latestClassification === 'passed' &&
5249 item . brokenCount === 0 &&
5350 item . flakyCount === 0 &&
5451 ( ( item . historicalBrokenCount ?? 0 ) > 0 || ( item . historicalFlakyCount ?? 0 ) > 0 ) ,
5552 ) ;
5653
54+ const broken = brokenItems . slice ( 0 , maxBroken ) ;
55+ const flaky = flakyItems . slice ( 0 , maxFlaky ) ;
56+ const review = reviewItems . slice ( 0 , maxReview ) ;
57+ const topItems = [ ...broken , ...flaky , ...review ] ;
58+
5759 const blocks = [
5860 {
5961 type : 'header' ,
@@ -71,7 +73,7 @@ export function createSlackBlocks(summary, dateDisplay, options) {
7173 text :
7274 `Period (UTC): ${ dateDisplay } | Repo: ${ repository } | Workflows: ${ workflowsScanned . join ( ', ' ) } | ` +
7375 `Failed CI Runs: ${ failedRunCount } /${ workflowCount } from ${ branch } ` +
74- `\nFound : ${ broken . length } broken, ${ flaky . length } flaky, ${ review . length } review` ,
76+ `\nTotal : ${ brokenItems . length } broken, ${ flakyItems . length } flaky, ${ reviewItems . length } review | Showing top ${ broken . length } , ${ flaky . length } , ${ review . length } ` ,
7577 } ,
7678 ] ,
7779 } ,
0 commit comments