Keep demo specialty seeding off the Queue API hot path.
Deploy Ladill Care / deploy (push) Successful in 1m52s

Enterprise reseeds were hanging on per-module Queue HTTP; activate specialties locally first, then provision once, and limit ticket sync to core contexts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 22:36:57 +00:00
co-authored by Cursor
parent db6d0617e9
commit fd2c854c57
+26 -7
View File
@@ -183,18 +183,24 @@ class DemoTenantSeeder
return;
}
// Core contexts only — specialty ticket backfill is best-effort and
// expensive (branch × module × Queue HTTP). Specialty pages still show
// Care-side waiting appointments from seedSpecialtyDemoData().
$contexts = [
CareQueueContexts::CONSULTATION,
CareQueueContexts::PHARMACY,
CareQueueContexts::LABORATORY,
CareQueueContexts::BILLING,
CareQueueContexts::IMAGING,
...array_keys(config('care.specialty_modules', [])),
];
foreach ($branches as $branch) {
foreach ($contexts as $context) {
$bridge->syncMissingTickets($organization, $context, (int) $branch->id, 100);
try {
$bridge->syncMissingTickets($organization, $context, (int) $branch->id, 25);
} catch (\Throwable) {
// Continue other contexts/branches if one Queue call fails.
}
}
}
} catch (\Throwable) {
@@ -573,22 +579,35 @@ class DemoTenantSeeder
private function seedSpecialtyModules(Organization $organization, string $ownerRef): void
{
// Pause Queue HTTP during per-module activate so Enterprise demos (many
// branches × specialties) do not spend minutes on remote timeouts.
$organization = $organization->fresh();
$settings = $organization->settings ?? [];
$queueEnabled = (bool) data_get($settings, 'queue_integration_enabled');
if ($queueEnabled) {
data_set($settings, 'queue_integration_enabled', false);
$organization->update(['settings' => $settings]);
}
$service = app(SpecialtyModuleService::class);
foreach (array_keys($service->catalog()) as $key) {
try {
// Activates depts + stubs. When queue_integration_enabled and QUEUE_API_*
// are configured, SpecialtyModuleService creates real Queue counters.
$service->activate($organization->fresh(), $ownerRef, $key);
} catch (\Throwable) {
// Demo seed should not fail if Queue API is unreachable; settings flag remains.
// Demo seed should not fail if activation hits an unexpected error.
}
}
if (data_get($organization->fresh()->settings, 'queue_integration_enabled')) {
if ($queueEnabled) {
$organization = $organization->fresh();
$settings = $organization->settings ?? [];
data_set($settings, 'queue_integration_enabled', true);
$organization->update(['settings' => $settings]);
try {
app(CareQueueProvisioner::class)->provisionOrganization($organization->fresh());
} catch (\Throwable) {
// Best-effort department queue stubs for Pro demo ticket flow.
// Best-effort department/specialty queue stubs for Pro demo ticket flow.
}
}
}