*/ protected function getViewData(): array { $window = SystemConsoleWindow::fromNullable((string) request()->query('window')); $start = $window->startAt(); /** @var Collection $runs */ $runs = OperationRun::query() ->with('tenant') ->where('created_at', '>=', $start) ->where('status', OperationRunStatus::Completed->value) ->where('outcome', OperationRunOutcome::Failed->value) ->latest('id') ->limit(8) ->get(); return [ 'windowLabel' => SystemConsoleWindow::options()[$window->value] ?? 'Last 24 hours', 'runs' => $runs->map(function (OperationRun $run): array { $failureSummary = is_array($run->failure_summary) ? $run->failure_summary : []; $primaryFailure = is_array($failureSummary[0] ?? null) ? $failureSummary[0] : []; $failureMessage = trim((string) ($primaryFailure['message'] ?? '')); return [ 'id' => (int) $run->getKey(), 'operation' => OperationCatalog::label((string) $run->type), 'tenant' => $run->tenant?->name ?? 'Tenantless', 'created_at' => $run->created_at?->diffForHumans() ?? '—', 'failure_message' => $failureMessage !== '' ? $failureMessage : 'No failure details available', 'url' => SystemOperationRunLinks::view($run), ]; }), 'runsUrl' => SystemOperationRunLinks::index(), ]; } }