Skip to content

Commit

Permalink
Add AC Submissions API
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanpingle committed Jan 28, 2024
1 parent 0be9b37 commit 8bf4bb4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ app.get("/", (req, res) => {
"/:username/contest/history": "get all contest history",
"/:username/submission": "get your last 20 submission",
"/:username/submission?limit=7": "get some of your last submission",
"/:username/ac_submission": "get your last 20 accepted submission",
"/:username/ac_submission?limit=7": "get some of your last accepted submission",
"/:username/calendar": "get your submission calendar",
},
problems: {
Expand Down Expand Up @@ -47,6 +49,7 @@ app.get("/:username/solved", leetcode.solvedProblem);
app.get("/:username/contest", leetcode.userContest);
app.get("/:username/contest/history", leetcode.userContestHistory);
app.get("/:username/submission", leetcode.submission);
app.get("/:username/ac_submission", leetcode.acSubmission);
app.get("/:username/calendar", leetcode.calendar);

app.listen(port, () => {
Expand Down
4 changes: 4 additions & 0 deletions leetCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const contestQuery = require("./src/GraphqlQuery/contest");
const dailyQuery = require("./src/GraphqlQuery/dailyProblem");
const selectProblemQuery = require("./src/GraphqlQuery/selectProblem");
const submissionQuery = require("./src/GraphqlQuery/recentSubmit");
const AcSubmissionQuery = require("./src/GraphqlQuery/recentAcSubmit");
const problemsQuery = require("./src/GraphqlQuery/problemList");

//API Fetch
Expand Down Expand Up @@ -39,6 +40,9 @@ exports.solvedProblem = (req, res) => {
exports.submission = (req, res) => {
userDetailsFetch(req, res, userData.formatSubmissionData, submissionQuery);
};
exports.acSubmission = (req, res) => {
userDetailsFetch(req, res, userData.formatAcSubmissionData, AcSubmissionQuery);
};
exports.calendar = (req, res) => {
userDetailsFetch(
req,
Expand Down
6 changes: 6 additions & 0 deletions src/FormatData/userData.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ exports.formatSubmissionData = (data) => {
submission: data.recentSubmissionList,
};
};
exports.formatAcSubmissionData = (data) => {
return {
count: data.recentAcSubmissionList.length,
submission: data.recentAcSubmissionList,
};
};
exports.formatSubmissionCalendarData = (data) => {
return {
submissionCalendar: data.matchedUser.submissionCalendar,
Expand Down
11 changes: 11 additions & 0 deletions src/GraphqlQuery/recentAcSubmit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let query = `query ($username: String!, $limit: Int) {
recentAcSubmissionList(username: $username, limit: $limit) {
title
titleSlug
timestamp
statusDisplay
lang
}
}`;

module.exports = query;

0 comments on commit 8bf4bb4

Please sign in to comment.