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:
@@ -6,17 +6,33 @@ namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
interface ProviderInterface
|
||||
{
|
||||
/** Fire the HTTP request(s) without blocking; returns an opaque handle for resolveFetch(). */
|
||||
public function startFetch(): mixed;
|
||||
/**
|
||||
* Fire the HTTP request(s) without blocking; the result is read later by
|
||||
* resolveFetch() so multiple providers' requests can be in flight at once.
|
||||
*
|
||||
* @param ?\DateTimeImmutable $since lower bound (inclusive); defaults to 365 days ago
|
||||
* @param ?\DateTimeImmutable $until upper bound (inclusive); defaults to now
|
||||
* @return mixed opaque handle to pass into resolveFetch()
|
||||
*/
|
||||
public function startFetch(?\DateTimeImmutable $since = null, ?\DateTimeImmutable $until = null): mixed;
|
||||
|
||||
/** @return array<string, int> date (Y-m-d) => contribution count */
|
||||
/**
|
||||
* Block on the handle from startFetch() and parse it into a per-day count map.
|
||||
*
|
||||
* @param mixed $handle the value returned by startFetch()
|
||||
* @return array<string, int> date (Y-m-d) => contribution count
|
||||
*/
|
||||
public function resolveFetch(mixed $handle): array;
|
||||
|
||||
/** Whether the required credentials/URL for this provider are all set. */
|
||||
public function isConfigured(): bool;
|
||||
|
||||
/** Short lowercase identifier for this provider, e.g. "github". */
|
||||
public function getName(): string;
|
||||
|
||||
/** Check reachability/credentials without fetching contribution data; used by the /health endpoint. */
|
||||
public function probe(): ProviderStatus;
|
||||
|
||||
/** Make a lightweight authenticated request to verify the provider is reachable; throws on failure. */
|
||||
public function ping(): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user