Skip to content

Commit 63d4e96

Browse files
authored
Merge pull request #41 from jsor-labs/retry-participation
Retry 3 times reading repo participation from the Github API
2 parents 6a9c9d6 + 6d6fa5d commit 63d4e96

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"symfony/process": "^3.2",
2525
"vlucas/phpdotenv": "^2.4",
2626
"elvanto/litemoji": "^1.0",
27-
"zendframework/zend-feed": "^2.10"
27+
"zendframework/zend-feed": "^2.10",
28+
"igorw/retry": "^1.0@dev"
2829
}
2930
}

composer.lock

Lines changed: 51 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/data.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Github\Client;
66
use Github\ResultPager;
7+
use function igorw\retry;
78
use Psr\Cache\CacheItemPoolInterface;
89

910
function components(Client $client, CacheItemPoolInterface $markdownCache): array
@@ -12,7 +13,18 @@ function components(Client $client, CacheItemPoolInterface $markdownCache): arra
1213
[$username, $repository] = explode('/', $component['repository']);
1314

1415
$component['contributors'] = $client->repo()->contributors($username, $repository);
15-
$component['participation'] = $client->repo()->participation($username, $repository);
16+
17+
$component['participation'] = retry(3, function () use ($client, $username, $repository){
18+
$participation = $client->repo()->participation($username, $repository);
19+
20+
if (!isset($participation['all'])) {
21+
throw new \RuntimeException(
22+
"Could not fetch participation for $username/$repository from the Github API"
23+
);
24+
}
25+
26+
return $participation;
27+
});
1628

1729
$apiReleases = (new ResultPager($client))
1830
->fetchAll(

0 commit comments

Comments
 (0)