(slug: string, viewerUserId?: string)
| 334 | } |
| 335 | |
| 336 | async getPersonBySlug(slug: string, viewerUserId?: string): Promise<PersonDetail | null> { |
| 337 | // Base user data |
| 338 | const userResult = await query<PersonListItem & { interests: string[]; linkedin_url: string | null; twitter_url: string | null; github_username: string | null }>( |
| 339 | `SELECT u.workos_user_id, u.slug, u.first_name, u.last_name, u.headline, u.bio, |
| 340 | u.avatar_url, u.expertise, u.interests, u.city, u.country, |
| 341 | u.open_to_coffee_chat, u.open_to_intros, u.linkedin_url, u.twitter_url, |
| 342 | u.github_username, CASE WHEN o.is_personal THEN NULL ELSE o.name END as organization_name |
| 343 | FROM users u |
| 344 | LEFT JOIN organizations o ON o.workos_organization_id = u.primary_organization_id |
| 345 | WHERE u.slug = $1 |
| 346 | AND (u.is_public = true OR u.workos_user_id = $2)`, |
| 347 | [slug, viewerUserId || ''] |
| 348 | ); |
| 349 | |
| 350 | const user = userResult.rows[0]; |
| 351 | if (!user) return null; |
| 352 | |
| 353 | // Fetch enrichments in parallel |
| 354 | const [points, badges, workingGroups, events, perspectives, registryContributions, connectionStatus] = await Promise.all([ |
| 355 | this.getUserPoints(user.workos_user_id), |
| 356 | this.getUserBadges(user.workos_user_id), |
| 357 | this.getUserWorkingGroups(user.workos_user_id), |
| 358 | this.getUserEvents(user.workos_user_id), |
| 359 | this.getUserPublishedContent(user.workos_user_id), |
| 360 | this.getUserRegistryContributions(user.workos_user_id), |
| 361 | viewerUserId ? this.getConnectionStatus(viewerUserId, user.workos_user_id) : Promise.resolve(null), |
| 362 | ]); |
| 363 | |
| 364 | return { |
| 365 | ...user, |
| 366 | total_points: points, |
| 367 | tier: this.getTierName(points), |
| 368 | badges, |
| 369 | working_groups: workingGroups, |
| 370 | events, |
| 371 | perspectives, |
| 372 | registry_contributions: registryContributions, |
| 373 | profile_completeness: this.getProfileCompleteness(user), |
| 374 | connection_status: connectionStatus?.status || null, |
| 375 | connection_id: connectionStatus?.id || null, |
| 376 | connection_direction: connectionStatus?.direction || null, |
| 377 | }; |
| 378 | } |
| 379 | |
| 380 | private async getUserWorkingGroups(userId: string): Promise<{ id: string; name: string; slug: string }[]> { |
| 381 | const result = await query<{ id: string; name: string; slug: string }>( |
no test coverage detected