Skip to content

Commit 92b4b86

Browse files
committed
Add result paer
1 parent 8c1ae3d commit 92b4b86

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

config/packages/github_api.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ services:
5252

5353
Github\Api\Issue\Timeline:
5454
factory: ['@Github\Api\Issue', timeline]
55+
calls:
56+
- [ configure ]
5557

5658
Github\Api\PullRequest:
5759
factory: ['@Github\Client', api]
@@ -70,5 +72,3 @@ services:
7072

7173
Github\Api\Repository\Actions\WorkflowRuns:
7274
factory: ['@Github\Api\Repo', workflowRuns]
73-
calls:
74-
- ['setPerPage', [100]]

src/Api/Workflow/GithubWorkflowApi.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,31 @@
77
use App\Api\Label\LabelApi;
88
use App\Model\Repository;
99
use Github\Api\Repository\Actions\WorkflowRuns;
10+
use Github\ResultPager;
1011
use Psr\Log\LoggerInterface;
1112

1213
/**
1314
* @author Tobias Nyholm <[email protected]>
1415
*/
1516
class GithubWorkflowApi implements WorkflowApi
1617
{
18+
private ResultPager $resultPager;
1719
private WorkflowRuns $workflowApi;
1820
private LoggerInterface $logger;
1921

20-
public function __construct(WorkflowRuns $workflowApi, LoggerInterface $logger)
22+
public function __construct(ResultPager $resultPager, WorkflowRuns $workflowApi, LoggerInterface $logger)
2123
{
24+
$this->resultPager = $resultPager;
2225
$this->workflowApi = $workflowApi;
2326
$this->logger = $logger;
2427
}
2528

2629
public function approveWorkflowsForPullRequest(Repository $repository, string $headRepository, string $headBranch): void
2730
{
28-
$result = $this->workflowApi->all($repository->getVendor(), $repository->getName(), [
31+
$result = $this->resultPager->fetchAllLazy($this->workflowApi, 'all', [$repository->getVendor(), $repository->getName(), [
2932
'branch' => $headBranch,
3033
'status' => 'action_required'
31-
]);
34+
]]);
3235

3336
foreach ($result['workflow_runs'] as $run) {
3437
if ($headRepository === $run['head_repository']['full_name']) {

0 commit comments

Comments
 (0)