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:
parent
fc2ae4fa3e
commit
89e31bb54e
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue