@@ -396,7 +396,7 @@ function allIncluded(outputTarget = 'email') {
396
396
log ( 'Making public requests' ) ;
397
397
}
398
398
399
- let issueUrl = `https://api.github.com/search/issues?q=author%3A${ githubUsername } +org%3A${ orgName } +created %3A${ startingDate } ..${ endingDate } &per_page=100` ;
399
+ let issueUrl = `https://api.github.com/search/issues?q=author%3A${ githubUsername } +org%3A${ orgName } +updated %3A${ startingDate } ..${ endingDate } &per_page=100` ;
400
400
let prUrl = `https://api.github.com/search/issues?q=commenter%3A${ githubUsername } +org%3A${ orgName } +updated%3A${ startingDate } ..${ endingDate } &per_page=100` ;
401
401
let userUrl = `https://api.github.com/users/${ githubUsername } ` ;
402
402
@@ -432,16 +432,20 @@ function allIncluded(outputTarget = 'email') {
432
432
githubUserData = await userRes . json ( ) ;
433
433
434
434
if ( githubIssuesData && githubIssuesData . items ) {
435
+ log ( 'Fetched githubIssuesData:' , githubIssuesData . items . length , 'items' ) ;
435
436
// Collect open PRs
436
437
const openPRs = githubIssuesData . items . filter (
437
438
item => item . pull_request && item . state === 'open'
438
439
) ;
440
+ log ( 'Open PRs for commit fetching:' , openPRs . map ( pr => pr . number ) ) ;
439
441
// Fetch commits for open PRs (batch)
440
442
if ( openPRs . length && githubToken ) {
441
443
const commitMap = await fetchCommitsForOpenPRs ( openPRs , githubToken , startingDate , endingDate ) ;
444
+ log ( 'Commit map returned from fetchCommitsForOpenPRs:' , commitMap ) ;
442
445
// Attach commits to PR objects
443
446
openPRs . forEach ( pr => {
444
447
pr . _allCommits = commitMap [ pr . number ] || [ ] ;
448
+ log ( `Attached ${ pr . _allCommits . length } commits to PR #${ pr . number } ` ) ;
445
449
} ) ;
446
450
}
447
451
}
@@ -489,6 +493,7 @@ function allIncluded(outputTarget = 'email') {
489
493
}
490
494
491
495
async function fetchCommitsForOpenPRs ( prs , githubToken , startDate , endDate ) {
496
+ log ( 'fetchCommitsForOpenPRs called with PRs:' , prs . map ( pr => pr . number ) , 'startDate:' , startDate , 'endDate:' , endDate ) ;
492
497
if ( ! prs . length ) return { } ;
493
498
const since = new Date ( startDate ) . toISOString ( ) ;
494
499
const until = new Date ( endDate + 'T23:59:59' ) . toISOString ( ) ;
@@ -514,11 +519,10 @@ function allIncluded(outputTarget = 'email') {
514
519
}
515
520
}
516
521
517
- }
518
- ` ;
522
+ }` ;
519
523
} ) . join ( '\n' ) ;
520
524
const query = `query { ${ queries } }` ;
521
-
525
+ log ( 'GraphQL query for commits:' , query ) ;
522
526
const res = await fetch ( 'https://api.github.com/graphql' , {
523
527
method : 'POST' ,
524
528
headers : {
@@ -527,19 +531,25 @@ function allIncluded(outputTarget = 'email') {
527
531
} ,
528
532
body : JSON . stringify ( { query } )
529
533
} ) ;
534
+ log ( 'fetchCommitsForOpenPRs response status:' , res . status ) ;
530
535
const data = await res . json ( ) ;
536
+ log ( 'fetchCommitsForOpenPRs response data:' , data ) ;
531
537
let commitMap = { } ;
532
538
prs . forEach ( ( pr , idx ) => {
533
539
const prData = data . data && data . data [ `pr${ idx } ` ] && data . data [ `pr${ idx } ` ] . pullRequest ;
534
540
if ( prData && prData . commits && prData . commits . nodes ) {
535
541
const allCommits = prData . commits . nodes . map ( n => n . commit ) ;
542
+ log ( `PR #${ pr . number } allCommits:` , allCommits ) ;
536
543
const filteredCommits = allCommits . filter ( commit => {
537
544
const commitDate = new Date ( commit . committedDate ) ;
538
545
const sinceDate = new Date ( since ) ;
539
546
const untilDate = new Date ( until ) ;
540
547
return commitDate >= sinceDate && commitDate <= untilDate ;
541
548
} ) ;
549
+ log ( `PR #${ pr . number } filteredCommits:` , filteredCommits ) ;
542
550
commitMap [ pr . number ] = filteredCommits ;
551
+ } else {
552
+ log ( `No commits found for PR #${ pr . number } ` ) ;
543
553
}
544
554
} ) ;
545
555
return commitMap ;
@@ -593,6 +603,7 @@ function allIncluded(outputTarget = 'email') {
593
603
user : githubUserData ?. login
594
604
} ) ;
595
605
606
+
596
607
lastWeekArray = [ ] ;
597
608
nextWeekArray = [ ] ;
598
609
reviewedPrsArray = [ ] ;
@@ -863,6 +874,7 @@ ${userReason}`;
863
874
}
864
875
865
876
async function writeGithubIssuesPrs ( ) {
877
+ log ( 'writeGithubIssuesPrs called' ) ;
866
878
let items = githubIssuesData . items ;
867
879
lastWeekArray = [ ] ;
868
880
nextWeekArray = [ ] ;
@@ -882,7 +894,6 @@ ${userReason}`;
882
894
} else if ( daysRange <= 7 ) {
883
895
useMergedStatus = true ;
884
896
}
885
-
886
897
// Collect PRs to batch fetch merged status
887
898
let prsToCheck = [ ] ;
888
899
for ( let i = 0 ; i < items . length ; i ++ ) {
@@ -901,6 +912,7 @@ ${userReason}`;
901
912
// Use GraphQL batching for all cases
902
913
if ( prsToCheck . length > 0 ) {
903
914
mergedStatusResults = await fetchPrsMergedStatusBatch ( prsToCheck , headers ) ;
915
+ log ( 'Merged status results (GraphQL):' , mergedStatusResults ) ;
904
916
}
905
917
} else if ( useMergedStatus ) {
906
918
if ( prsToCheck . length > 30 ) {
@@ -914,9 +926,9 @@ ${userReason}`;
914
926
let merged = await fetchPrMergedStatusREST ( pr . owner , pr . repo , pr . number , headers ) ;
915
927
mergedStatusResults [ `${ pr . owner } /${ pr . repo } #${ pr . number } ` ] = merged ;
916
928
}
929
+ log ( 'Merged status results (REST):' , mergedStatusResults ) ;
917
930
}
918
931
}
919
-
920
932
for ( let i = 0 ; i < items . length ; i ++ ) {
921
933
let item = items [ i ] ;
922
934
let html_url = item . html_url ;
@@ -925,12 +937,10 @@ ${userReason}`;
925
937
let title = item . title ;
926
938
let number = item . number ;
927
939
let li = '' ;
928
-
929
940
let isDraft = false ;
930
941
if ( item . pull_request && typeof item . draft !== 'undefined' ) {
931
942
isDraft = item . draft ;
932
943
}
933
-
934
944
if ( item . pull_request ) {
935
945
936
946
const prCreatedDate = new Date ( item . created_at ) ;
@@ -940,20 +950,25 @@ ${userReason}`;
940
950
941
951
if ( ! isNewPR ) {
942
952
const hasCommitsInRange = showCommits && item . _allCommits && item . _allCommits . length > 0 ;
953
+
943
954
if ( ! hasCommitsInRange ) {
955
+
944
956
continue ; //skip these prs - created outside daterange with no commits
957
+ } else {
958
+
945
959
}
946
- }
960
+ } else {
947
961
962
+ }
948
963
const prAction = isNewPR ? 'Made PR' : 'Existing PR' ;
949
-
950
964
if ( isDraft ) {
951
965
li = `<li><i>(${ project } )</i> - ${ prAction } (#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ pr_draft_button } </li>` ;
952
966
} else if ( item . state === 'open' ) {
953
967
li = `<li><i>(${ project } )</i> - ${ prAction } (#${ number } ) - <a href='${ html_url } '>${ title } </a> ${ pr_open_button } ` ;
954
968
if ( showCommits && item . _allCommits && item . _allCommits . length && ! isNewPR ) {
969
+ log ( `[PR DEBUG] Rendering commits for existing PR #${ number } :` , item . _allCommits ) ;
955
970
item . _allCommits . forEach ( commit => {
956
- 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>` ;
971
+ 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>` ;
957
972
} ) ;
958
973
}
959
974
li += `</li>` ;
0 commit comments