Memoize specialty nav and branch lookups to stop per-request N+1.
Deploy Ladill Care / deploy (push) Successful in 28s

Sidebar was re-querying practitioners for every specialty module and also
calling ensureDefaultModulesProvisioned on each page render, which showed
up as multi-second PHP-FPM slow logs on Care.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-19 16:02:16 +00:00
co-authored by Cursor
parent 1d3db4f803
commit b44ed50fe7
4 changed files with 72 additions and 24 deletions
+3 -6
View File
@@ -81,12 +81,9 @@
// Desk specialists skip this group (redundant single-desk list); dashboard cards remain.
if ($permissions->handlesFloorCare($member) && $organization) {
$specialtyService = app(\App\Services\Care\SpecialtyModuleService::class);
$specialtyService->ensureDefaultModulesProvisioned(
$organization,
(string) $organization->owner_ref,
);
if ($specialtyService->shouldShowSpecialtyNav($organization, $member)) {
foreach ($specialtyService->enabledModulesForMember($organization, $member) as $item) {
$specialtyModulesForNav = $specialtyService->enabledModulesForMember($organization, $member);
if ($specialtyModulesForNav !== [] && $specialtyService->shouldShowSpecialtyNav($organization, $member)) {
foreach ($specialtyModulesForNav as $item) {
$key = $item['key'];
$label = $item['definition']['nav_label'] ?? $item['definition']['label'] ?? $key;
$nav[] = [