@@ -43,7 +43,6 @@ function allIncluded(outputTarget = 'email') {
43
43
let prsReviewDataProcessed = false ;
44
44
let showOpenLabel = true ;
45
45
let showCommits = false ;
46
- let numCommits = 5 ; //default
47
46
let userReason = '' ;
48
47
49
48
let pr_open_button =
@@ -78,7 +77,6 @@ function allIncluded(outputTarget = 'email') {
78
77
'yesterdayContribution' ,
79
78
'userReason' ,
80
79
'showCommits' ,
81
- 'numCommits' ,
82
80
'githubCache' ,
83
81
'cacheInput' ,
84
82
'orgName'
@@ -179,9 +177,6 @@ function allIncluded(outputTarget = 'email') {
179
177
if ( items . orgName ) {
180
178
orgName = items . orgName ;
181
179
}
182
- if ( items . numCommits ) {
183
- numCommits = items . numCommits ;
184
- }
185
180
} ,
186
181
) ;
187
182
}
@@ -445,11 +440,11 @@ function allIncluded(outputTarget = 'email') {
445
440
) ;
446
441
// Fetch commits for open PRs (batch)
447
442
if ( openPRs . length && githubToken ) {
448
- const commitMap = await fetchCommitsForOpenPRs ( openPRs , githubToken , numCommits ) ;
443
+ const commitMap = await fetchCommitsForOpenPRs ( openPRs , githubToken , startingDate , endingDate ) ;
449
444
// Attach commits to PR objects
450
445
openPRs . forEach ( pr => {
451
446
pr . _allCommits = commitMap [ pr . number ] || [ ] ;
452
- pr . _lastCommits = pr . _allCommits . slice ( 0 , numCommits ) ;
447
+ pr . _lastCommits = pr . _allCommits ;
453
448
} ) ;
454
449
}
455
450
}
@@ -496,16 +491,18 @@ function allIncluded(outputTarget = 'email') {
496
491
}
497
492
}
498
493
499
- async function fetchCommitsForOpenPRs ( prs , githubToken , numCommits = 5 ) {
494
+ async function fetchCommitsForOpenPRs ( prs , githubToken , startDate , endDate ) {
500
495
if ( ! prs . length ) return { } ;
496
+ const since = new Date ( startDate ) . toISOString ( ) ;
497
+ const until = new Date ( endDate + 'T23:59:59' ) . toISOString ( ) ;
501
498
let queries = prs . map ( ( pr , idx ) => {
502
499
const repoParts = pr . repository_url . split ( '/' ) ;
503
500
const owner = repoParts [ repoParts . length - 2 ] ;
504
501
const repo = repoParts [ repoParts . length - 1 ] ;
505
502
return `
506
503
pr${ idx } : repository(owner: "${ owner } ", name: "${ repo } ") {
507
504
pullRequest(number: ${ pr . number } ) {
508
- commits(last: ${ numCommits } ) {
505
+ commits(first: 100 ) {
509
506
nodes {
510
507
commit {
511
508
messageHeadline
@@ -537,7 +534,14 @@ function allIncluded(outputTarget = 'email') {
537
534
prs . forEach ( ( pr , idx ) => {
538
535
const prData = data . data && data . data [ `pr${ idx } ` ] && data . data [ `pr${ idx } ` ] . pullRequest ;
539
536
if ( prData && prData . commits && prData . commits . nodes ) {
540
- commitMap [ pr . number ] = prData . commits . nodes . map ( n => n . commit ) ;
537
+ const allCommits = prData . commits . nodes . map ( n => n . commit ) ;
538
+ const filteredCommits = allCommits . filter ( commit => {
539
+ const commitDate = new Date ( commit . committedDate ) ;
540
+ const sinceDate = new Date ( since ) ;
541
+ const untilDate = new Date ( until ) ;
542
+ return commitDate >= sinceDate && commitDate <= untilDate ;
543
+ } ) ;
544
+ commitMap [ pr . number ] = filteredCommits ;
541
545
}
542
546
} ) ;
543
547
return commitMap ;
@@ -935,7 +939,6 @@ ${userReason}`;
935
939
} else if ( item . state === 'open' ) {
936
940
li = `<li><i>(${ project } )</i> - Made PR (#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ pr_open_button } ` ;
937
941
if ( showCommits && item . _lastCommits && item . _lastCommits . length ) {
938
- item . _lastCommits = item . _allCommits . slice ( 0 , numCommits ) ;
939
942
item . _lastCommits . forEach ( commit => {
940
943
li += `<li style="list-style: disc; margin: 0 0 0 20px; padding: 0; color: #666;"><span style="color:#2563eb;">${ commit . messageHeadline } </span><span style="color:#666; font-size: 11px;"> (${ new Date ( commit . committedDate ) . toLocaleString ( ) } )</span></li>` ;
941
944
} ) ;
0 commit comments