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

Class Query

packages/core/src/query.ts:41–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41export class Query {
42 async us(username: string, headers?: Record<string, string>): Promise<FetchedData> {
43 const lc = new LeetCode();
44 const { data } = await lc.graphql({
45 operationName: "data",
46 variables: { username },
47 query: `
48 query data($username: String!) {
49 problems: allQuestionsCount {
50 difficulty
51 count
52 }
53 user: matchedUser(username: $username) {
54 username
55 profile {
56 realname: realName
57 about: aboutMe
58 avatar: userAvatar
59 skills: skillTags
60 country: countryName
61 ranking
62 }
63 submits: submitStatsGlobal {
64 ac: acSubmissionNum { difficulty count }
65 }
66 }
67 submissions: recentSubmissionList(username: $username, limit: 10) {
68 id
69 title
70 slug: titleSlug
71 time: timestamp
72 status: statusDisplay
73 lang
74 }
75 contest: userContestRanking(username: $username) {
76 rating
77 ranking: globalRanking
78 badge {
79 name
80 }
81 }
82 }`,
83 headers,
84 });
85
86 if (!data?.user) {
87 throw new Error("User Not Found");
88 }
89
90 const result: FetchedData = {
91 profile: {
92 username: data.user.username,
93 realname: data.user.profile.realname,
94 about: data.user.profile.about,
95 avatar: data.user.profile.avatar,
96 skills: data.user.profile.skills,
97 country: data.user.profile.country,
98 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected