@@ -35,35 +35,36 @@ const page = async ({ params: { username } }) => {
3535 console . log ( 'Username:' , username ) ;
3636
3737 const userInfo = await fetchUserInfo ( username ) ;
38- // console.log(userInfo);
3938 if ( ! userInfo ) return notFound ( ) ;
4039
41- await RecentProfiles . findOneAndUpdate (
42- { username } ,
40+ const updateRecentProfilesDb = async ( ) =>
41+ await RecentProfiles . findOneAndUpdate (
42+ { username } ,
43+ {
44+ name : userInfo . name ?? userInfo . username ,
45+ username : userInfo . username ,
46+ following : userInfo . following . totalCount ,
47+ followers : userInfo . followers . totalCount ,
48+ avatarUrl : userInfo . avatarUrl ,
49+ } ,
50+ { upsert : true , new : true , setDefaultsOnInsert : true } ,
51+ ) ;
52+
53+ const [
54+ userActivity ,
4355 {
44- name : userInfo . name ?? userInfo . username ,
45- username : userInfo . username ,
46- following : userInfo . following . totalCount ,
47- followers : userInfo . followers . totalCount ,
48- avatarUrl : userInfo . avatarUrl ,
56+ languagesSize,
57+ contributionCalendar,
58+ commitsPerRepo,
59+ starsPerRepo,
60+ reposPerLanguages,
61+ starsPerLanguages,
62+ popularRepositories,
63+ userStats,
64+ topContributions,
65+ followUp,
4966 } ,
50- { upsert : true , new : true , setDefaultsOnInsert : true } ,
51- ) ;
52-
53- const userActivity = await fetchActivity ( username ) ;
54-
55- const {
56- languagesSize,
57- contributionCalendar,
58- commitsPerRepo,
59- starsPerRepo,
60- reposPerLanguages,
61- starsPerLanguages,
62- popularRepositories,
63- userStats,
64- topContributions,
65- followUp,
66- } = await fetchUserData ( username ) ;
67+ ] = await Promise . all ( [ fetchActivity ( username ) , fetchUserData ( username ) , updateRecentProfilesDb ( ) ] ) ;
6768
6869 return (
6970 < main className = "mx-auto max-w-screen-xl space-y-8 px-3 pb-10 md:space-y-16" >
0 commit comments