*/ protected function getViewData(): array { $tenant = Filament::getTenant(); if (! $tenant instanceof Tenant) { return [ 'pollingInterval' => null, 'openDriftFindings' => 0, 'highSeverityDriftFindings' => 0, 'activeRuns' => 0, 'inventoryActiveRuns' => 0, ]; } $tenantId = (int) $tenant->getKey(); $openDriftFindings = (int) Finding::query() ->where('tenant_id', $tenantId) ->where('finding_type', Finding::FINDING_TYPE_DRIFT) ->where('status', Finding::STATUS_NEW) ->count(); $highSeverityDriftFindings = (int) Finding::query() ->where('tenant_id', $tenantId) ->where('finding_type', Finding::FINDING_TYPE_DRIFT) ->where('status', Finding::STATUS_NEW) ->where('severity', Finding::SEVERITY_HIGH) ->count(); $activeRuns = (int) OperationRun::query() ->where('tenant_id', $tenantId) ->active() ->count(); $inventoryActiveRuns = (int) OperationRun::query() ->where('tenant_id', $tenantId) ->where('type', 'inventory.sync') ->active() ->count(); return [ 'pollingInterval' => ActiveRuns::existForTenant($tenant) ? '10s' : null, 'openDriftFindings' => $openDriftFindings, 'highSeverityDriftFindings' => $highSeverityDriftFindings, 'activeRuns' => $activeRuns, 'inventoryActiveRuns' => $inventoryActiveRuns, ]; } }