9
9
use Github \Api \PullRequest \Review ;
10
10
use Github \Api \Search ;
11
11
use Github \Exception \RuntimeException ;
12
+ use Github \ResultPager ;
12
13
13
14
class GithubIssueApi implements IssueApi
14
15
{
16
+ private $ resultPager ;
15
17
private $ issueCommentApi ;
16
18
private $ reviewApi ;
17
19
private $ issueApi ;
18
20
private $ searchApi ;
19
21
private $ timelineApi ;
20
22
private $ botUsername ;
21
23
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 )
23
25
{
26
+ $ this ->resultPager = $ resultPager ;
24
27
$ this ->issueCommentApi = $ issueCommentApi ;
25
28
$ this ->reviewApi = $ reviewApi ;
26
29
$ this ->issueApi = $ issueApi ;
@@ -38,7 +41,7 @@ public function open(Repository $repository, string $title, string $body, array
38
41
];
39
42
40
43
$ 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 ' ]);
42
45
foreach ($ existingIssues ['items ' ] ?? [] as $ issue ) {
43
46
$ issueNumber = $ issue ['number ' ];
44
47
}
@@ -109,7 +112,7 @@ public function commentOnIssue(Repository $repository, $issueNumber, string $com
109
112
110
113
public function findStaleIssues (Repository $ repository , \DateTimeImmutable $ noUpdateAfter ): array
111
114
{
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 ' ]);
113
116
114
117
return $ issues ['items ' ] ?? [];
115
118
}
0 commit comments