From 2e771e3675865224d2739cb9e977ecf3c336fc99 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Tue, 17 Jan 2023 12:58:20 -0700 Subject: [PATCH 1/2] Update stats.php --- src/stats.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/stats.php b/src/stats.php index 73bac082..4dc6d49e 100644 --- a/src/stats.php +++ b/src/stats.php @@ -83,6 +83,7 @@ function executeContributionGraphRequests(string $user, array $years): array removeGitHubToken($tokens[$year]); } error_log("First attempt to decode response for $user's $year contributions failed. $message"); + error_log("Contents: $contents"); // retry request $query = buildContributionGraphQuery($user, $year); $token = getGitHubToken(); @@ -96,6 +97,7 @@ function executeContributionGraphRequests(string $user, array $years): array removeGitHubToken($token); } error_log("Failed to decode response for $user's $year contributions after 2 attempts. $message"); + error_log("Contents: $contents"); continue; } } @@ -119,8 +121,12 @@ function getContributionGraphs(string $user): array { // get the list of years the user has contributed and the current year's contribution graph $currentYear = intval(date("Y")); - $responses = executeContributionGraphRequests($user, [$currentYear]); - $contributionYears = $responses[$currentYear]->data->user->contributionsCollection->contributionYears; + $responses = []; + $contributionYears = $responses[$currentYear]->data->user->contributionsCollection->contributionYears ?? []; + // if there are no contribution years, an API error must have occurred + if (empty($contributionYears)) { + throw new AssertionError("Failed to retrieve contributions. This is likely a GitHub API issue.", 500); + } // remove the current year from the list since it's already been fetched $contributionYears = array_filter($contributionYears, function ($year) use ($currentYear) { return $year !== $currentYear; From 07011494f54b70c3d47062d4226e9056ed9ff38f Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Tue, 17 Jan 2023 12:59:48 -0700 Subject: [PATCH 2/2] Update stats.php --- src/stats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stats.php b/src/stats.php index 4dc6d49e..d6551652 100644 --- a/src/stats.php +++ b/src/stats.php @@ -121,7 +121,7 @@ function getContributionGraphs(string $user): array { // get the list of years the user has contributed and the current year's contribution graph $currentYear = intval(date("Y")); - $responses = []; + $responses = executeContributionGraphRequests($user, [$currentYear]); $contributionYears = $responses[$currentYear]->data->user->contributionsCollection->contributionYears ?? []; // if there are no contribution years, an API error must have occurred if (empty($contributionYears)) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy