@@ -121,7 +121,44 @@ export class LeetCodeCNService implements LeetCodeBaseService {
121121 }
122122
123123 async fetchUserProfile ( username : string ) : Promise < any > {
124- return await this . leetCodeApi . user ( username ) ;
124+ const originalProfile = await this . leetCodeApi . user ( username ) ;
125+ 126+ if ( ! originalProfile || ! originalProfile . userProfilePublicProfile ) {
127+ return originalProfile ;
128+ }
129+ 130+ const publicProfile = originalProfile . userProfilePublicProfile || { } ;
131+ const userProfile = publicProfile . profile || { } ;
132+ const skillSet = userProfile . skillSet || { } ;
133+ 134+ const simplifiedProfile = {
135+ username : userProfile . userSlug ,
136+ questionProgress : originalProfile . userProfileUserQuestionProgress ,
137+ siteRanking : publicProfile . siteRanking ,
138+ profile : {
139+ userSlug : userProfile . userSlug ,
140+ realName : userProfile . realName ,
141+ userAvatar : userProfile . userAvatar ,
142+ globalLocation : userProfile . globalLocation ,
143+ school : userProfile . school ?. name ,
144+ socialAccounts : ( userProfile . socialAccounts || [ ] ) . filter (
145+ ( account : any ) => ! ! account . profileUrl
146+ ) ,
147+ skillSet : {
148+ topics : ( skillSet . topics || [ ] ) . map (
149+ ( topic : any ) => topic . slug
150+ ) ,
151+ topicAreaScores : ( skillSet . topicAreaScores || [ ] ) . map (
152+ ( item : any ) => ( {
153+ slug : item . topicArea ?. slug ,
154+ score : item . score
155+ } )
156+ )
157+ }
158+ }
159+ } ;
160+ 161+ return simplifiedProfile ;
125162 }
126163
127164 async fetchUserContestRanking (
@@ -210,17 +247,28 @@ export class LeetCodeCNService implements LeetCodeBaseService {
210247 filters . searchKeywords = searchKeywords ;
211248 }
212249
213- const response = await this . leetCodeApi . graphql ( {
250+ const { data } = await this . leetCodeApi . graphql ( {
214251 query : SEARCH_PROBLEMS_QUERY ,
215- variables : {
216- categorySlug : category ,
217- limit,
218- skip : offset ,
219- filters
220- }
252+ variables : { categorySlug : category , limit, skip : offset , filters }
221253 } ) ;
222254
223- return response . data ?. problemsetQuestionList ;
255+ const questionList = data ?. problemsetQuestionList ;
256+ if ( ! questionList ) {
257+ return { hasMore : false , total : 0 , questions : [ ] } ;
258+ }
259+ 260+ return {
261+ hasMore : questionList . hasMore ,
262+ total : questionList . total ,
263+ questions : questionList . questions . map ( ( q : any ) => ( {
264+ title : q . title ,
265+ titleCn : q . titleCn ,
266+ titleSlug : q . titleSlug ,
267+ difficulty : q . difficulty ,
268+ acRate : q . acRate ,
269+ topicTags : q . topicTags . map ( ( tag : any ) => tag . slug )
270+ } ) )
271+ } ;
224272 }
225273
226274 async fetchUserProgressQuestionList ( options ?: {
0 commit comments