Skip to content

Commit c3756d5

Browse files
committed
Use ResultPager
1 parent 5aa0813 commit c3756d5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Api/Issue/GithubIssueApi.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
use Github\Api\PullRequest\Review;
1010
use Github\Api\Search;
1111
use Github\Exception\RuntimeException;
12+
use Github\ResultPager;
1213

1314
class 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
}

src/Api/PullRequest/GithubPullRequestApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function findReviewer(Repository $repository, $number, string $type)
4949

5050
public function getAuthorCount(Repository $repository, string $author): int
5151
{
52-
$result = $this->search->issues(sprintf('is:pr repo:%s author:%s', $repository->getFullName(), $author), 'updated', 'desc', ['per_page' => 100]);
52+
$result = $this->search->issues(sprintf('is:pr repo:%s author:%s', $repository->getFullName(), $author), 'updated', 'desc');
5353

5454
return $result['total_count'];
5555
}

0 commit comments

Comments
 (0)