From 19a6b1baf11b2f1f6dff6c7bc04ab15e880e954d Mon Sep 17 00:00:00 2001 From: Aman L Date: Sat, 23 Sep 2023 18:44:04 +0530 Subject: [PATCH] Added memory back to judge0 req, fixed a bug, commented out console.log() lines --- api/controllers/questions.js | 2 +- api/controllers/submission.js | 16 +++++++++------- api/controllers/testCasesController.js | 2 +- api/middleware/jwtMiddleware.js | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/api/controllers/questions.js b/api/controllers/questions.js index b37471e..118d5fd 100644 --- a/api/controllers/questions.js +++ b/api/controllers/questions.js @@ -86,7 +86,7 @@ async function getByRound(req, res) { async function deleteQuestion(req, res) { try { const deletedItem = await ques.findByIdAndDelete(req.params.id); - console.log(req.body.id); + //console.log(req.body.id); const testCases = await TestCaseModel.find() .where(`_id: ${req.params.id}`) diff --git a/api/controllers/submission.js b/api/controllers/submission.js index 0120ef6..1e77aa7 100644 --- a/api/controllers/submission.js +++ b/api/controllers/submission.js @@ -150,6 +150,8 @@ class submission { ), cpu_time_limit: current.time * multipler < 15 ? current.time * multipler : 15, + memory: + current.memory * multipler<2048 ? 2048 : current.memory*multipler //redirect_stderr_to_stdout: true, }); const group = current.group; @@ -198,7 +200,7 @@ class submission { "/submissions/batch?tokens=" + str.toString() + "&base64_encoded=true&fields=status_id,stderr,compile_output,expected_output,stdout,time"; - console.log(url); + //console.log(url); let completion = false; let data_sent_back = { error: [false, false, false, false], //false means it passed that grp @@ -311,7 +313,7 @@ class submission { //comparing the score with the existing score and picking the best one data_sent_back.Score = !check || score >= check.score ? score : check.score; - console.log(data_sent_back.Score, score); + //console.log(data_sent_back.Score, score); //If new score is higher or equal to the existing score, then sub DB is updated if (data_sent_back.Score == score) { @@ -326,6 +328,7 @@ class submission { await this.create_score(reg_no); } else { data_sent_back.Sub_db = "No changes in Sub DB"; + await this.create_score(reg_no); } //Creation of allPassesAt field when all testcases are passed @@ -366,8 +369,7 @@ class submission { ]); const score = ele[0].total; return User.updateOne({ regNo: user }, { score: score }) - .then(() => console.log("Score = " + score)) - .catch(() => console.error("Error occured while saving scores")); + .catch(() => console.error("Error occured while saving scores \nRegno :"+regNo+"\tScore :"+score)); } async get_reg_no(req, res) { @@ -394,12 +396,12 @@ class submission { async get_all(req, res) { const { regno } = req.params; - console.log(regno); + //console.log(regno); const record = await submission_db.find( { regNo: regno }, "code score question_id lastResults" ); - console.log(record); + //console.log(record); if (record.length == 0) { res.status(400).json({ Error: "Invalid regNo", @@ -484,7 +486,7 @@ class submission { return [key, leaderboard[key]]; }); items.sort(function(a,b){ - console.log(a[1][0]); + //console.log(a[1][0]); if(a[1][0]>b[1][0]) return -1; if(a[1][0]b[1][1]) return 1; diff --git a/api/controllers/testCasesController.js b/api/controllers/testCasesController.js index c368351..b22667b 100644 --- a/api/controllers/testCasesController.js +++ b/api/controllers/testCasesController.js @@ -77,7 +77,7 @@ const updateTestCase = async (req, res) => { } const updated = await QuestionModel.findById(question); - console.log(updated); + //console.log(updated); updated.testCases.push(testCase._id); await updated.save(); diff --git a/api/middleware/jwtMiddleware.js b/api/middleware/jwtMiddleware.js index a8c22bf..c5225e8 100644 --- a/api/middleware/jwtMiddleware.js +++ b/api/middleware/jwtMiddleware.js @@ -79,7 +79,7 @@ async function verifyQuestion(req, res, next) { try { const user = await User.findOne({ regNo: req.user.regNo }); const ques = await Ques.findOne({ _id: question_id }); - console.log(ques); + //console.log(ques); if (!ques) { return res.status(400).json({ message: "Question not found" }); }