From ed53c05177b3e1907d2a89611bfa1ce3c584b433 Mon Sep 17 00:00:00 2001 From: Tom Witkowski Date: Wed, 28 Aug 2024 12:21:38 +0200 Subject: [PATCH] cache ecology value --- app/Http/Controllers/HomeController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index b39c42b..bc8f741 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -8,6 +8,8 @@ use App\Models\Sponsor; use App\Models\Trustee; use Astrotomic\Ecologi\Ecologi; +use Carbon\CarbonInterval; +use Illuminate\Support\Facades\Cache; use Illuminate\View\View; class HomeController @@ -53,7 +55,11 @@ public function __invoke(Ecologi $ecologi): View + Application::pluck('contributor_stats')->map->sum()->sum(), 'stars' => Package::sum('github_stars') + Application::sum('github_stars'), - 'trees' => $ecologi->reporting()->getTrees('astrotomic'), + 'trees' => Cache::remember( + key: 'ecologi.reporting.trees', + ttl: CarbonInterval::day(), + callback: fn () => $ecologi->reporting()->getTrees('astrotomic') + ), ], 'apps' => $apps, 'promos' => $promos,