@@ -43,7 +43,6 @@ function allIncluded(outputTarget = 'email') {
4343 let prsReviewDataProcessed = false ;
4444 let showOpenLabel = true ;
4545 let showCommits = false ;
46- let numCommits = 5 ; //default
4746 let userReason = '' ;
4847
4948 let pr_open_button =
@@ -78,7 +77,6 @@ function allIncluded(outputTarget = 'email') {
7877 'yesterdayContribution' ,
7978 'userReason' ,
8079 'showCommits' ,
81- 'numCommits' ,
8280 'githubCache' ,
8381 'cacheInput' ,
8482 'orgName'
@@ -179,9 +177,6 @@ function allIncluded(outputTarget = 'email') {
179177 if ( items . orgName ) {
180178 orgName = items . orgName ;
181179 }
182- if ( items . numCommits ) {
183- numCommits = items . numCommits ;
184- }
185180 } ,
186181 ) ;
187182 }
@@ -445,11 +440,11 @@ function allIncluded(outputTarget = 'email') {
445440 ) ;
446441 // Fetch commits for open PRs (batch)
447442 if ( openPRs . length && githubToken ) {
448- const commitMap = await fetchCommitsForOpenPRs ( openPRs , githubToken , numCommits ) ;
443+ const commitMap = await fetchCommitsForOpenPRs ( openPRs , githubToken , startingDate , endingDate ) ;
449444 // Attach commits to PR objects
450445 openPRs . forEach ( pr => {
451446 pr . _allCommits = commitMap [ pr . number ] || [ ] ;
452- pr . _lastCommits = pr . _allCommits . slice ( 0 , numCommits ) ;
447+ pr . _lastCommits = pr . _allCommits ;
453448 } ) ;
454449 }
455450 }
@@ -496,16 +491,18 @@ function allIncluded(outputTarget = 'email') {
496491 }
497492 }
498493
499- async function fetchCommitsForOpenPRs ( prs , githubToken , numCommits = 5 ) {
494+ async function fetchCommitsForOpenPRs ( prs , githubToken , startDate , endDate ) {
500495 if ( ! prs . length ) return { } ;
496+ const since = new Date ( startDate ) . toISOString ( ) ;
497+ const until = new Date ( endDate + 'T23:59:59' ) . toISOString ( ) ;
501498 let queries = prs . map ( ( pr , idx ) => {
502499 const repoParts = pr . repository_url . split ( '/' ) ;
503500 const owner = repoParts [ repoParts . length - 2 ] ;
504501 const repo = repoParts [ repoParts . length - 1 ] ;
505502 return `
506503 pr${ idx } : repository(owner: "${ owner } ", name: "${ repo } ") {
507504 pullRequest(number: ${ pr . number } ) {
508- commits(last: ${ numCommits } ) {
505+ commits(first: 100 ) {
509506 nodes {
510507 commit {
511508 messageHeadline
@@ -537,7 +534,14 @@ function allIncluded(outputTarget = 'email') {
537534 prs . forEach ( ( pr , idx ) => {
538535 const prData = data . data && data . data [ `pr${ idx } ` ] && data . data [ `pr${ idx } ` ] . pullRequest ;
539536 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 ;
541545 }
542546 } ) ;
543547 return commitMap ;
@@ -935,7 +939,6 @@ ${userReason}`;
935939 } else if ( item . state === 'open' ) {
936940 li = `<li><i>(${ project } )</i> - Made PR (#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ pr_open_button } ` ;
937941 if ( showCommits && item . _lastCommits && item . _lastCommits . length ) {
938- item . _lastCommits = item . _allCommits . slice ( 0 , numCommits ) ;
939942 item . _lastCommits . forEach ( commit => {
940943 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>` ;
941944 } ) ;
0 commit comments