Create real Queue counters when specialty modules activate.
Deploy Ladill Care / deploy (push) Successful in 1m39s
Deploy Ladill Care / deploy (push) Successful in 1m39s
Wire module activation to the Queue create/upsert APIs, persist queue and counter UUIDs on Care stubs, and soft-deactivate on module off so embedded service counters work without manual setup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -157,7 +157,23 @@ class SpecialtyModuleService
|
||||
$organization->update(['settings' => $settings]);
|
||||
|
||||
if (data_get($organization->fresh()->settings, 'queue_integration_enabled') && $this->queue->configured()) {
|
||||
$this->queue->syncSpecialtyQueueStubs($ownerRef, $queueStubs);
|
||||
try {
|
||||
$synced = $this->queue->syncSpecialtyQueueStubs($ownerRef, $queueStubs);
|
||||
$settings = $organization->fresh()->settings ?? [];
|
||||
$provisioning = is_array($settings['specialty_module_provisioning'] ?? null)
|
||||
? $settings['specialty_module_provisioning']
|
||||
: [];
|
||||
$provisioning[$key] = array_merge($provisioning[$key] ?? [], [
|
||||
'queues' => $synced,
|
||||
]);
|
||||
$settings['specialty_module_provisioning'] = $provisioning;
|
||||
$organization->update(['settings' => $settings]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('specialty_module.queue_sync_failed', [
|
||||
'key' => $key,
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,8 +201,27 @@ class SpecialtyModuleService
|
||||
}
|
||||
|
||||
$queues = is_array($record['queues'] ?? null) ? $record['queues'] : [];
|
||||
foreach ($queues as $i => $queue) {
|
||||
$queues[$i]['active'] = false;
|
||||
|
||||
if (
|
||||
data_get($settings, 'queue_integration_enabled')
|
||||
&& $this->queue->configured()
|
||||
&& $queues !== []
|
||||
) {
|
||||
try {
|
||||
$queues = $this->queue->deactivateSpecialtyQueueStubs($ownerRef, $queues);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('specialty_module.queue_deactivate_failed', [
|
||||
'key' => $key,
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
foreach ($queues as $i => $queue) {
|
||||
$queues[$i]['active'] = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($queues as $i => $queue) {
|
||||
$queues[$i]['active'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$provisioning[$key] = array_merge($record, [
|
||||
@@ -246,8 +281,8 @@ class SpecialtyModuleService
|
||||
}
|
||||
|
||||
/**
|
||||
* Care-side queue stubs (branch-aware). Full counter creation lives in Queue admin;
|
||||
* stubs document intended queues and feed embedded panels / future API sync.
|
||||
* Care-side queue stubs (branch-aware). When Queue integration is enabled,
|
||||
* activate() creates/links real Queue queues + counters and stores UUIDs here.
|
||||
*
|
||||
* @param array<string, mixed> $definition
|
||||
* @return list<array<string, mixed>>
|
||||
@@ -263,8 +298,16 @@ class SpecialtyModuleService
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$existingByBranch = collect(
|
||||
data_get($organization->settings, "specialty_module_provisioning.{$key}.queues", [])
|
||||
)->keyBy(fn ($q) => (string) ($q['branch_id'] ?? ''));
|
||||
|
||||
$stubs = [];
|
||||
foreach ($branches as $branch) {
|
||||
$prior = is_array($existingByBranch->get((string) $branch->id))
|
||||
? $existingByBranch->get((string) $branch->id)
|
||||
: [];
|
||||
|
||||
$stubs[] = [
|
||||
'module' => $key,
|
||||
'branch_id' => $branch->id,
|
||||
@@ -273,6 +316,12 @@ class SpecialtyModuleService
|
||||
'prefix' => (string) ($definition['queue_prefix'] ?? strtoupper(substr($key, 0, 3))),
|
||||
'active' => true,
|
||||
'synced' => false,
|
||||
'queue_uuid' => $prior['queue_uuid'] ?? null,
|
||||
'counter_uuid' => $prior['counter_uuid'] ?? null,
|
||||
'queue_external_key' => $prior['queue_external_key']
|
||||
?? "care:specialty:{$key}:queue:{$branch->id}",
|
||||
'counter_external_key' => $prior['counter_external_key']
|
||||
?? "care:specialty:{$key}:counter:{$branch->id}",
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user