From 0e4501adbc8a9bf8eba100aeb8bceaed7f53df29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20Falco=CC=81n?= Date: Sat, 18 Jul 2026 19:38:04 +0200 Subject: [PATCH] perf(subscriptions): batch the price-experiment feature resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolving PriceExperiment for the shared pricing prop added a separate Pennant select+insert on every authenticated request, blowing the per-page query budget (PageQueryCountTest). Warm all three features this response reads in one values() call so the later per-feature reads hit Pennant's in-memory cache — back to one round-trip, no extra queries. --- app/Http/Middleware/HandleInertiaRequests.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index e827dee4..737c7989 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -6,6 +6,7 @@ use App\Enums\BankingConnectionStatus; use App\Enums\BankingProvider; use App\Features\CalculateBalancesOnImport; use App\Features\Mcp; +use App\Features\PriceExperiment; use App\Jobs\PurgeResidualEncryptionArtifactsJob; use App\Models\BankingConnection; use App\Services\CurrencyOptions; @@ -70,6 +71,18 @@ class HandleInertiaRequests extends Middleware PurgeResidualEncryptionArtifactsJob::dispatch($user); } + // Warm every Pennant feature this response reads in a single round-trip, so + // the per-feature reads below (the price-experiment pricing variant and the + // feature flags) hit Pennant's in-memory cache instead of each issuing its + // own select + insert. + if ($user) { + Feature::for($user)->values([ + CalculateBalancesOnImport::class, + Mcp::class, + PriceExperiment::class, + ]); + } + return [ ...parent::share($request), 'flash' => [