fix: keep feature flag query count and shared-data shape in sync

- batch CalculateBalancesOnImport and CustomMonthStartDay into a single
  Pennant values() lookup so the settings page stays under its query
  threshold
- include customMonthStartDay in the shared feature flags assertion
This commit is contained in:
Víctor Falcón 2026-05-29 15:47:49 +02:00
parent fc2ae4fa3e
commit 89e31bb54e
2 changed files with 11 additions and 17 deletions

View File

@ -165,26 +165,19 @@ class HandleInertiaRequests extends Middleware
{
$user = request()->user();
if (! $user) {
return [
'cashflow' => true,
'calculateBalancesOnImport' => false,
'customMonthStartDay' => false,
'transactionAnalysis' => false,
];
}
$features = Feature::for($user)->values([
CalculateBalancesOnImport::class,
CustomMonthStartDay::class,
TransactionAnalysis::class,
]);
$flags = $user
? Feature::for($user)->values([
CalculateBalancesOnImport::class,
CustomMonthStartDay::class,
TransactionAnalysis::class,
])
: [];
return [
'cashflow' => true,
'calculateBalancesOnImport' => $features[CalculateBalancesOnImport::class] !== false,
'customMonthStartDay' => $features[CustomMonthStartDay::class] !== false,
'transactionAnalysis' => $features[TransactionAnalysis::class] !== false,
'calculateBalancesOnImport' => $flags[CalculateBalancesOnImport::class] ?? false,
'customMonthStartDay' => $flags[CustomMonthStartDay::class] ?? false,
'transactionAnalysis' => $flags[TransactionAnalysis::class] ?? false,
];
}

View File

@ -43,6 +43,7 @@ test('shared feature flags do not include coinbase flag', function () {
expect($props['features'])->toBe([
'cashflow' => true,
'calculateBalancesOnImport' => false,
'customMonthStartDay' => false,
'transactionAnalysis' => false,
]);
});