feat(store): fetch contributions incrementally and persist history in SQLite
Bound each provider's startFetch()/resolveFetch() to an optional since/until window, wire a SQLite-backed ContributionStore into ContributionAggregator (fetch only the trailing window past the last stored date, merge into the store, prune by CONTRIBUTIONS_RETENTION_DAYS), and add a graph:contributions:refetch command to force a full or ranged re-fetch in <=365-day chunks. This is the root fix for the full 365-day-refetch timeout that used to hit on every cache miss.
This commit is contained in:
@@ -44,12 +44,13 @@ final class GitHubProvider implements ProviderInterface
|
||||
])->getContent();
|
||||
}
|
||||
|
||||
public function startFetch(): ResponseInterface
|
||||
/** Fires the GraphQL contributionsCollection query bounded by $since/$until. */
|
||||
public function startFetch(?\DateTimeImmutable $since = null, ?\DateTimeImmutable $until = null): ResponseInterface
|
||||
{
|
||||
$this->logger->debug('GitHubProvider: fetching contributions', ['user' => $this->username]);
|
||||
|
||||
$from = (new \DateTimeImmutable('-365 days'))->format('Y-m-d\T00:00:00\Z');
|
||||
$to = (new \DateTimeImmutable())->format('Y-m-d\T23:59:59\Z');
|
||||
$from = ($since ?? new \DateTimeImmutable('-365 days'))->format('Y-m-d\T00:00:00\Z');
|
||||
$to = ($until ?? new \DateTimeImmutable())->format('Y-m-d\T23:59:59\Z');
|
||||
|
||||
$query = sprintf(
|
||||
'query { user(login: %s) { contributionsCollection(from: %s, to: %s) { contributionCalendar { weeks { contributionDays { date contributionCount } } } } } }',
|
||||
@@ -71,7 +72,10 @@ final class GitHubProvider implements ProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int> date (Y-m-d) => contribution count
|
||||
* Parses the GraphQL response into a per-day count map, skipping zero-count days.
|
||||
*
|
||||
* @param ResponseInterface $handle the response returned by startFetch()
|
||||
* @return array<string, int> date (Y-m-d) => contribution count
|
||||
*/
|
||||
public function resolveFetch(mixed $handle): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user