badgeVariant(); $profileKey = strtolower(trim((string) ($auditRun['profile_key'] ?? ''))); $profileLabel = $profileKey; if ($profileKey === 'users') { $profileLabel = t('Users'); } elseif ($profileKey === 'departments') { $profileLabel = t('Departments'); } $mappedCsv = trim((string) ($auditRun['mapped_targets_csv'] ?? '')); $mappedFields = []; if ($mappedCsv !== '') { $mappedFields = array_values(array_filter(array_map('trim', explode(',', $mappedCsv)), static fn ($item) => $item !== '')); } $errorCodesJson = trim((string) ($auditRun['error_codes_json'] ?? '')); $errorCodes = []; if ($errorCodesJson !== '') { $decoded = json_decode($errorCodesJson, true); if (is_array($decoded)) { foreach ($decoded as $code => $count) { $code = trim((string) $code); $count = (int) $count; if ($code === '' || $count <= 0) { continue; } $errorCodes[$code] = $count; } } } arsort($errorCodes); $userLabel = trim((string) ($auditRun['user_display_name'] ?? '')); $userEmail = trim((string) ($auditRun['user_email'] ?? '')); if ($userLabel === '') { $userLabel = $userEmail !== '' ? $userEmail : '-'; } $tenantLabel = trim((string) ($auditRun['current_tenant_description'] ?? '')); if ($tenantLabel === '') { $tenantLabel = '-'; } ?>