From 596260bb852d5920bced1ebdf1ebece6f14942df Mon Sep 17 00:00:00 2001 From: Haylan Date: Tue, 7 Jul 2026 13:31:21 +0200 Subject: [PATCH] refactor(gitea): make GiteaProvider fetch non-blocking startFetch() fires the heatmap GET and returns the response without reading it; resolveFetch() does the .toArray()/parse/log work. --- src/Service/Provider/GiteaProvider.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Service/Provider/GiteaProvider.php b/src/Service/Provider/GiteaProvider.php index 411093d..050b319 100644 --- a/src/Service/Provider/GiteaProvider.php +++ b/src/Service/Provider/GiteaProvider.php @@ -6,6 +6,7 @@ namespace App\Service\Provider; use Psr\Log\LoggerInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; +use Symfony\Contracts\HttpClient\ResponseInterface; /** * Fetches contribution data from the Gitea heatmap endpoint. @@ -46,20 +47,24 @@ final class GiteaProvider implements ProviderInterface ])->getContent(); } - /** - * @return array date (Y-m-d) => contribution count - */ - public function fetch(): array + public function startFetch(): ResponseInterface { $baseUrl = rtrim($this->baseUrl, '/'); $this->logger->debug('GiteaProvider: fetching contributions', ['user' => $this->username, 'url' => $baseUrl]); - $response = $this->client->request('GET', "$baseUrl/api/v1/users/{$this->username}/heatmap", [ + return $this->client->request('GET', "$baseUrl/api/v1/users/{$this->username}/heatmap", [ 'headers' => ['Authorization' => "token {$this->token}"], ]); + } - $data = $response->toArray(); + /** + * @return array date (Y-m-d) => contribution count + */ + public function resolveFetch(mixed $handle): array + { + /** @var ResponseInterface $handle */ + $data = $handle->toArray(); $cutoff = (new \DateTimeImmutable('-365 days'))->getTimestamp(); $result = [];