@@ -121,7 +121,44 @@ export class LeetCodeCNService implements LeetCodeBaseService {
121
121
}
122
122
123
123
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 ;
125
162
}
126
163
127
164
async fetchUserContestRanking (
@@ -210,17 +247,28 @@ export class LeetCodeCNService implements LeetCodeBaseService {
210
247
filters . searchKeywords = searchKeywords ;
211
248
}
212
249
213
- const response = await this . leetCodeApi . graphql ( {
250
+ const { data } = await this . leetCodeApi . graphql ( {
214
251
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 }
221
253
} ) ;
222
254
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
+ } ;
224
272
}
225
273
226
274
async fetchUserProgressQuestionList ( options ?: {
0 commit comments