Restore Care queue FIFO after demo skip left tickets Unassigned.
Deploy Ladill Care / deploy (push) Successful in 1m2s
Deploy Ladill Care / deploy (push) Successful in 1m2s
Provision one branch/context at a time instead of the whole org, fall back to a desk when doctor counters are catching up, sync pharmacy tickets in Care list order on page load, and seed waiting_at/queue_position for demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -476,6 +476,9 @@ class CareQueueProvisioner
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure Queue resources exist for one context + branch only.
|
||||
* Never fans out across every department × branch (that hung demo queues).
|
||||
*
|
||||
* @return array{queue_uuid: ?string, counter_uuid: ?string, queue_external_key: string, counter_external_key: string, synced: bool, points: list<array<string, mixed>>, routing_mode: string}|null
|
||||
*/
|
||||
public function ensure(
|
||||
@@ -507,8 +510,58 @@ class CareQueueProvisioner
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->provisionOrganization($organization->fresh());
|
||||
$this->provisionContextBranch($organization->fresh(), $context, $branchId);
|
||||
|
||||
return $this->resourcesFor($organization->fresh(), $context, $branchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provision a single department queue for one branch (idempotent).
|
||||
*/
|
||||
public function provisionContextBranch(Organization $organization, string $context, int $branchId): ?array
|
||||
{
|
||||
if (! $this->shouldProvision($organization)) {
|
||||
return $this->resourcesFor($organization, $context, $branchId);
|
||||
}
|
||||
|
||||
$meta = CareQueueContexts::departments()[$context] ?? null;
|
||||
if ($meta === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$branch = Branch::owned((string) $organization->owner_ref)
|
||||
->where('organization_id', $organization->id)
|
||||
->whereKey($branchId)
|
||||
->first();
|
||||
if (! $branch) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$provisioning = (array) data_get($organization->settings, 'department_queue_provisioning', []);
|
||||
$queues = is_array($provisioning[$context]['queues'] ?? null)
|
||||
? $provisioning[$context]['queues']
|
||||
: [];
|
||||
$byBranch = collect($queues)->keyBy(fn ($q) => (string) ($q['branch_id'] ?? ''));
|
||||
$prior = $byBranch->get((string) $branch->id, []);
|
||||
|
||||
$stub = $this->provisionBranchDepartment(
|
||||
$organization,
|
||||
(string) $organization->owner_ref,
|
||||
$context,
|
||||
$meta,
|
||||
$branch,
|
||||
is_array($prior) ? $prior : [],
|
||||
);
|
||||
$byBranch->put((string) $branch->id, $stub);
|
||||
|
||||
$provisioning[$context] = [
|
||||
'queues' => $byBranch->values()->all(),
|
||||
];
|
||||
|
||||
$settings = $organization->settings ?? [];
|
||||
$settings['department_queue_provisioning'] = $provisioning;
|
||||
$organization->update(['settings' => $settings]);
|
||||
|
||||
return $stub;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user