Skip to content

Commit

Permalink
Don't panic when GH API does not return
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Mar 20, 2023
1 parent aa0d212 commit c99c8e5
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions public/about.php
Expand Up @@ -55,24 +55,26 @@ function url_get_contents($Url)
return $output;
}

// Cache the contributors
if (!getRedis("contributors")) {
$contributorsResponse = url_get_contents("https://api.github.com/repos/interclip/interclip/contributors", false);
$contributorsJSON = json_decode($contributorsResponse, true);

// Get the login of every contributor
$contributors = array();
foreach ($contributorsJSON as $contributor) {
// Don't push if the contributor is a bot
if ($contributor['type'] !== "Bot" && !str_contains(strtolower($contributor['login']), "bot")) {
array_push($contributors, $contributor['login']);
try {
if (!getRedis("contributors")) {
$contributorsResponse = url_get_contents("https://api.github.com/repos/interclip/interclip/contributors", false);
$contributorsJSON = json_decode($contributorsResponse, true);

// Get the login of every contributor
$contributors = array();
foreach ($contributorsJSON as $contributor) {
// Don't push if the contributor is a bot
if ($contributor['type'] !== "Bot" && !str_contains(strtolower($contributor['login']), "bot")) {
array_push($contributors, $contributor['login']);
}
}
}

// Cache the contributors
storeRedis("contributors", json_encode($contributors), 60 * 60 * 24);
} else {
$contributors = json_decode(getRedis("contributors"));
// Cache the contributors
storeRedis("contributors", json_encode($contributors), 60 * 60 * 24);
} else {
$contributors = json_decode(getRedis("contributors"));
}
} catch (Error $e) {
}
?>
<main id="maincontent">
Expand Down

0 comments on commit c99c8e5

Please sign in to comment.