MCPcopy Create free account
hub / github.com/JacobLinCool/LeetCode-Stats-Card / cn

Method cn

packages/core/src/query.ts:119–194  ·  view source on GitHub ↗
(username: string, headers?: Record<string, string>)

Source from the content-addressed store, hash-verified

117 }
118
119 async cn(username: string, headers?: Record<string, string>): Promise<FetchedData> {
120 const lc = new LeetCodeCN();
121 const { data } = await lc.graphql({
122 operationName: "data",
123 variables: { username },
124 query: `
125 query data($username: String!) {
126 progress: userProfileUserQuestionProgress(userSlug: $username) {
127 ac: numAcceptedQuestions { difficulty count }
128 wa: numFailedQuestions { difficulty count }
129 un: numUntouchedQuestions { difficulty count }
130 }
131 user: userProfilePublicProfile(userSlug: $username) {
132 username
133 ranking: siteRanking
134 profile {
135 realname: realName
136 about: aboutMe
137 avatar: userAvatar
138 skills: skillTags
139 country: countryName
140 }
141 }
142 submissions: recentSubmitted(userSlug: $username) {
143 id: submissionId
144 status
145 lang
146 time: submitTime
147 question {
148 title: translatedTitle
149 slug: titleSlug
150 }
151 }
152 }`,
153 headers,
154 });
155
156 if (!data?.user) {
157 throw new Error("User Not Found");
158 }
159
160 const result: FetchedData = {
161 profile: {
162 username: data.user.username,
163 realname: data.user.profile.realname,
164 about: data.user.profile.about,
165 avatar: data.user.profile.avatar,
166 skills: data.user.profile.skills,
167 country: data.user.profile.country,
168 },
169 problem: {
170 easy: getCNProblemStats("EASY", data.progress),
171 medium: getCNProblemStats("MEDIUM", data.progress),
172 hard: getCNProblemStats("HARD", data.progress),
173 ranking: data.user.ranking,
174 },
175 submissions: data.submissions.map(
176 (x: {

Callers 2

_fetchMethod · 0.80
query.test.tsFile · 0.80

Calls 1

getCNProblemStatsFunction · 0.85

Tested by

no test coverage detected