diff --git a/app/Services/Care/DemoTenantSeeder.php b/app/Services/Care/DemoTenantSeeder.php index 2082897..57af886 100644 --- a/app/Services/Care/DemoTenantSeeder.php +++ b/app/Services/Care/DemoTenantSeeder.php @@ -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. } } }