MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / getHubData

Method getHubData

server/src/db/community-db.ts:880–929  ·  view source on GitHub ↗
(userId: string)

Source from the content-addressed store, hash-verified

878 // =====================================================
879
880 async getHubData(userId: string): Promise<HubData> {
881 // Fetch user profile
882 const profileResult = await query<CommunityProfile & { first_name: string; last_name: string; city: string | null; country: string | null; email: string | null }>(
883 `SELECT workos_user_id, slug, headline, bio, avatar_url, expertise, interests,
884 linkedin_url, twitter_url, github_username, is_public, open_to_coffee_chat, open_to_intros,
885 first_name, last_name, city, country, email
886 FROM users WHERE workos_user_id = $1`,
887 [userId]
888 );
889
890 const profile = profileResult.rows[0];
891 if (!profile) {
892 throw new Error('User not found');
893 }
894
895 // Parallel fetch all hub data
896 const [
897 totalPoints,
898 badges,
899 suggestedConnections,
900 recentProfiles,
901 upcomingEvents,
902 workingGroups,
903 connectionCount,
904 pendingRequestCount,
905 ] = await Promise.all([
906 this.getUserPoints(userId),
907 this.getUserBadges(userId),
908 this.getSuggestedConnections(userId, 4),
909 this.getRecentPublicProfiles(5),
910 this.getUpcomingEvents(userId, profile.email ?? undefined),
911 this.getUserWorkingGroupsWithCount(userId),
912 this.getConnectionCount(userId),
913 this.getPendingRequestCount(userId),
914 ]);
915
916 return {
917 profile,
918 profile_completeness: this.getProfileCompleteness(profile),
919 total_points: totalPoints,
920 tier: this.getTierName(totalPoints),
921 badges,
922 suggested_connections: suggestedConnections,
923 recent_profiles: recentProfiles.filter(p => p.workos_user_id !== userId),
924 upcoming_events: upcomingEvents,
925 working_groups: workingGroups,
926 connection_count: connectionCount,
927 pending_request_count: pendingRequestCount,
928 };
929 }
930
931 private async getUpcomingEvents(userId: string, userEmail?: string): Promise<{ id: string; title: string; start_time: string; co_attendee_count: number }[]> {
932 // Match registrations by workos_user_id OR email (Luma-synced registrations only have email)

Callers 1

createCommunityRoutersFunction · 0.80

Calls 10

getUserPointsMethod · 0.95
getUserBadgesMethod · 0.95
getUpcomingEventsMethod · 0.95
getConnectionCountMethod · 0.95
getTierNameMethod · 0.95

Tested by

no test coverage detected