@@ -60,36 +60,36 @@ async def get_user_data(username: str, force: bool = True) -> dict:
6060 if res .status_code == 200 :
6161 return res .json ()
6262
63- profile_data = await GitHubProfileFetcher .fetch_user_profile (username )
63+ # Parallel fetch profile + contributions
64+ profile_data , contributions_data = await asyncio .gather (
65+ GitHubProfileFetcher .fetch_user_profile (username ),
66+ asyncio .to_thread (
67+ GitHubContributionsFetcher .fetch_recent_contributions ,
68+ username ,
69+ Settings .CONTRIBUTION_DAYS
70+ )
71+ )
6472
6573 # Early return if GitHub fetch failed
6674 if "error" in profile_data :
6775 return profile_data
6876
69- contributions_data = await asyncio .to_thread (
70- GitHubContributionsFetcher .fetch_recent_contributions ,
71- username ,
72- Settings .CONTRIBUTION_DAYS
73- )
74-
7577 ai_generator = AIDescriptionGenerator ()
78+
79+ # Parallel AI summary generation
7680 try :
77- profile_summary = await asyncio .to_thread (
78- ai_generator .generate_profile_summary , profile_data
81+ profile_summary , activity_summary = await asyncio .gather (
82+ asyncio .to_thread (ai_generator .generate_profile_summary , profile_data ),
83+ asyncio .to_thread (ai_generator .generate_activity_summary , contributions_data ) if contributions_data else None ,
84+ return_exceptions = True
7985 )
8086 except Exception as e :
81- logger .exception ("Failed to generate profile summary for user %s" , username )
87+ logger .exception ("Failed to generate AI summaries for user %s" , username )
8288 profile_summary = None
89+ activity_summary = None
8390
8491 if contributions_data :
85- try :
86- activity_summary = await asyncio .to_thread (
87- ai_generator .generate_activity_summary , contributions_data
88- )
89- profile_data ['activity_summary' ] = activity_summary if activity_summary else {}
90- except Exception as e :
91- logger .exception ("Failed to generate activity summary for user %s" , username )
92- profile_data ['activity_summary' ] = {}
92+ profile_data ['activity_summary' ] = activity_summary if activity_summary else {}
9393
9494 profile_data ['profile_summary' ] = profile_summary
9595 return profile_data
0 commit comments