Optimierung 3.4: Performance (Logging terminable, Single-Purchase memoisiert)
- LogApiUsage als terminable Middleware: der ApiUsageLog-INSERT laeuft nach gesendeter Antwort und verlaengert nicht mehr die Request-Dauer. Startzeit wird ueber ein Request-Attribut uebergeben (terminate() laeuft auf frischer Instanz). - User::openSinglePurchaseCount() memoisiert die offenen Einmalkaeufe pro Request. Vorher wurde derselbe grantingSubmission-Count im Status-Widget mehrfach (Quota-Total, Quota-Remaining, openSinglePurchases) plus ein exists() in hasActiveBooking abgesetzt -> jetzt eine Query. - CustomerCompanyContext::selectedCompany() nutzt eine einzige first()-Query statt exists()+first(); das Verwerfen nicht (mehr) erreichbarer Auswahlen bleibt erhalten. - LegacySubscriptionService::cancelBundleFor() ist ein einziges Bulk-Update statt Update-pro-Iteration (UserPaymentOption hat keine Observer/Events). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f2c349ac2c
commit
9ed429fe74
6 changed files with 56 additions and 19 deletions
|
|
@ -42,15 +42,13 @@ class LegacySubscriptionService
|
|||
*/
|
||||
public function cancelBundleFor(User $user): int
|
||||
{
|
||||
$posts = $this->grandfatheredFor($user);
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$post->update([
|
||||
return UserPaymentOption::query()
|
||||
->where('user_id', $user->getKey())
|
||||
->where('status', UserPaymentOptionStatus::Grandfathered->value)
|
||||
->whereNull('cancelled_at')
|
||||
->update([
|
||||
'status' => UserPaymentOptionStatus::Cancelled->value,
|
||||
'cancelled_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $posts->count();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue