($e['hash'] ?? '') === $hash); $matches = array_values($matches); if (empty($matches)) { error_response('Error not found', 404); } $totalCount = array_sum(array_column($matches, 'count')); $uniqueSessions = array_unique(array_column($matches, 'session_id')); $firstSeen = min(array_column($matches, 'first_seen')); $lastSeen = max(array_column($matches, 'last_seen')); json_response([ 'success' => true, 'hash' => $hash, 'total_occurrences' => count($matches), 'total_count' => $totalCount, 'unique_sessions' => count($uniqueSessions), 'first_seen' => $firstSeen, 'last_seen' => $lastSeen, 'type' => $matches[0]['type'] ?? 'unknown', 'severity' => $matches[0]['severity'] ?? 'error', 'category' => $matches[0]['category'] ?? 'runtime', 'sample_message' => $matches[0]['message'] ?? '', 'sample_stack' => $matches[0]['stack'] ?? null, 'occurrences' => array_slice($matches, 0, 20), ]);