99use Github \Api \PullRequest \Review ;
1010use Github \Api \Search ;
1111use Github \Exception \RuntimeException ;
12+ use Github \ResultPager ;
1213
1314class GithubIssueApi implements IssueApi
1415{
16+ private $ resultPager ;
1517 private $ issueCommentApi ;
1618 private $ reviewApi ;
1719 private $ issueApi ;
1820 private $ searchApi ;
1921 private $ timelineApi ;
2022 private $ botUsername ;
2123
22- public function __construct (Comments $ issueCommentApi , Review $ reviewApi , Issue $ issueApi , Search $ searchApi , Timeline $ timelineApi , string $ botUsername )
24+ public function __construct (ResultPager $ resultPager , Comments $ issueCommentApi , Review $ reviewApi , Issue $ issueApi , Search $ searchApi , Timeline $ timelineApi , string $ botUsername )
2325 {
26+ $ this ->resultPager = $ resultPager ;
2427 $ this ->issueCommentApi = $ issueCommentApi ;
2528 $ this ->reviewApi = $ reviewApi ;
2629 $ this ->issueApi = $ issueApi ;
@@ -38,7 +41,7 @@ public function open(Repository $repository, string $title, string $body, array
3841 ];
3942
4043 $ issueNumber = null ;
41- $ existingIssues = $ this ->searchApi -> issues ( sprintf ('repo:%s "%s" is:open author:%s ' , $ repository ->getFullName (), $ title , $ this ->botUsername ), 'updated ' , 'desc ' , [ ' per_page ' => 100 ]);
44+ $ existingIssues = $ this ->resultPager -> fetchAllLazy ( $ this -> searchApi , ' issues ' , [ sprintf ('repo:%s "%s" is:open author:%s ' , $ repository ->getFullName (), $ title , $ this ->botUsername ), 'updated ' , 'desc ' ]);
4245 foreach ($ existingIssues ['items ' ] ?? [] as $ issue ) {
4346 $ issueNumber = $ issue ['number ' ];
4447 }
@@ -109,7 +112,7 @@ public function commentOnIssue(Repository $repository, $issueNumber, string $com
109112
110113 public function findStaleIssues (Repository $ repository , \DateTimeImmutable $ noUpdateAfter ): array
111114 {
112- $ issues = $ this ->searchApi -> issues ( sprintf ('repo:%s is:issue -label:"Keep open" is:open updated:<%s ' , $ repository ->getFullName (), $ noUpdateAfter ->format ('Y-m-d ' )), 'updated ' , 'desc ' , [ ' per_page ' => 100 ]);
115+ $ issues = $ this ->resultPager -> fetchAll ( $ this -> searchApi , ' issues ' , [ sprintf ('repo:%s is:issue -label:"Keep open" is:open updated:<%s ' , $ repository ->getFullName (), $ noUpdateAfter ->format ('Y-m-d ' )), 'updated ' , 'desc ' ]);
113116
114117 return $ issues ['items ' ] ?? [];
115118 }
0 commit comments