From fcf841f7ada1e0b11e5f8f79eeb6ff8e8ec70fd6 Mon Sep 17 00:00:00 2001 From: Haylan Date: Tue, 7 Jul 2026 13:31:36 +0200 Subject: [PATCH] feat(aggregator): fetch all providers concurrently aggregate() now fires every configured provider's startFetch() in one pass before resolving any of them, so wall-clock cost is roughly max(providers) instead of sum(providers). Partial-failure isolation and per-date summation behavior are unchanged. --- src/Service/ContributionAggregator.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Service/ContributionAggregator.php b/src/Service/ContributionAggregator.php index 24d37cb..8a8b59a 100644 --- a/src/Service/ContributionAggregator.php +++ b/src/Service/ContributionAggregator.php @@ -19,7 +19,7 @@ final class ContributionAggregator /** @return array */ public function aggregate(): array { - $contributions = []; + $pending = []; /** @var ProviderInterface $provider */ foreach ($this->providers as $provider) { @@ -28,7 +28,17 @@ final class ContributionAggregator } try { - foreach ($provider->fetch() as $date => $count) { + $pending[] = [$provider, $provider->startFetch()]; + } catch (\Throwable $e) { + $this->logger->warning(sprintf('%s fetch failed: %s', $provider::class, $e->getMessage()), ['exception' => $e]); + } + } + + $contributions = []; + + foreach ($pending as [$provider, $handle]) { + try { + foreach ($provider->resolveFetch($handle) as $date => $count) { $contributions[$date] = ($contributions[$date] ?? 0) + $count; } } catch (\Throwable $e) {