Speed up Queue board loads by dropping sync and gate side effects.
Deploy Ladill Care / deploy (push) Successful in 1m22s

Stop issuing missing tickets and refreshing financial gates on every GET;
eager-load advances, cap board rows, and cache specialty department maps.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 19:50:03 +00:00
co-authored by Cursor
parent 93c7a71ee5
commit a5bbbe23b1
10 changed files with 512 additions and 76 deletions
+27 -4
View File
@@ -19,6 +19,9 @@ use Illuminate\Support\Facades\Log;
*/
class CareQueueBridge
{
/** @var array<int, array<int, string>> organization_id => [department_id => specialty_key] */
protected array $specialtyDepartmentMaps = [];
public function __construct(
protected CareQueueEngine $engine,
protected CareQueueProvisioner $provisioner,
@@ -49,14 +52,34 @@ class CareQueueBridge
return CareQueueContexts::CONSULTATION;
}
return $this->specialtyDepartmentMap($organization)[$departmentId]
?? CareQueueContexts::CONSULTATION;
}
/**
* Department id specialty module key for this org (request-scoped cache).
*
* @return array<int, string>
*/
public function specialtyDepartmentMap(Organization $organization): array
{
$orgId = (int) $organization->id;
if (isset($this->specialtyDepartmentMaps[$orgId])) {
return $this->specialtyDepartmentMaps[$orgId];
}
$map = [];
foreach ($this->specialties->enabledKeys($organization) as $key) {
$deptIds = data_get($organization->settings, "specialty_module_provisioning.{$key}.department_ids", []);
if (is_array($deptIds) && in_array($departmentId, array_map('intval', $deptIds), true)) {
return $key;
if (! is_array($deptIds)) {
continue;
}
foreach ($deptIds as $deptId) {
$map[(int) $deptId] = $key;
}
}
return CareQueueContexts::CONSULTATION;
return $this->specialtyDepartmentMaps[$orgId] = $map;
}
public function contextForPractitioner(Organization $organization, ?Practitioner $practitioner): string
@@ -496,7 +519,7 @@ class CareQueueBridge
];
}
$resources = $this->provisioner->ensure($organization->fresh(), $context, $branchId);
$resources = $this->provisioner->ensure($organization, $context, $branchId);
return [
'enabled' => true,