Save to database #13

Merged
haylan merged 42 commits from save-to-database into main 2026-07-12 21:51:57 +00:00
Showing only changes of commit 596260bb85 - Show all commits
+11 -6
View File
@@ -6,6 +6,7 @@ namespace App\Service\Provider;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
/** /**
* Fetches contribution data from the Gitea heatmap endpoint. * Fetches contribution data from the Gitea heatmap endpoint.
@@ -46,20 +47,24 @@ final class GiteaProvider implements ProviderInterface
])->getContent(); ])->getContent();
} }
/** public function startFetch(): ResponseInterface
* @return array<string, int> date (Y-m-d) => contribution count
*/
public function fetch(): array
{ {
$baseUrl = rtrim($this->baseUrl, '/'); $baseUrl = rtrim($this->baseUrl, '/');
$this->logger->debug('GiteaProvider: fetching contributions', ['user' => $this->username, 'url' => $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}"], 'headers' => ['Authorization' => "token {$this->token}"],
]); ]);
}
$data = $response->toArray(); /**
* @return array<string, int> date (Y-m-d) => contribution count
*/
public function resolveFetch(mixed $handle): array
{
/** @var ResponseInterface $handle */
$data = $handle->toArray();
$cutoff = (new \DateTimeImmutable('-365 days'))->getTimestamp(); $cutoff = (new \DateTimeImmutable('-365 days'))->getTimestamp();
$result = []; $result = [];