From 9c05e0120095f53f23b97b0568a47e6d47cfaa40 Mon Sep 17 00:00:00 2001 From: hankeke303 Date: Mon, 13 May 2019 22:05:33 +0800 Subject: [PATCH 1/4] fix code unable to be submitted in contests --- modules/problem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/problem.js b/modules/problem.js index fd25b15..751b89f 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -637,7 +637,7 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1 code_length: size, language: null, user_id: curUser.id, - problem_id: req.params.id, + problem_id: id, is_public: problem.is_public }); } else { @@ -658,7 +658,7 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1 code_length: Buffer.from(code).length, language: req.body.language, user_id: curUser.id, - problem_id: req.params.id, + problem_id: id, is_public: problem.is_public }); } From 637a6d422622d7ec2bf4f4033507ca00b2938c48 Mon Sep 17 00:00:00 2001 From: hankeke303 Date: Mon, 13 May 2019 22:08:23 +0800 Subject: [PATCH 2/4] fix code unable to be judged in contests --- models/contest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/models/contest.ts b/models/contest.ts index 1f279da..c5e986f 100644 --- a/models/contest.ts +++ b/models/contest.ts @@ -129,6 +129,7 @@ export default class Contest extends Model { contest_id: this.id, user_id: judge_state.user_id }); + await player.save(); } await player.updateScore(judge_state); From 5be0c5582090cc1eef9dba4191b444e73622e6c7 Mon Sep 17 00:00:00 2001 From: hankeke303 Date: Mon, 13 May 2019 22:11:21 +0800 Subject: [PATCH 3/4] fix rating calculation not work --- modules/admin.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/admin.js b/modules/admin.js index b9725ab..1e930cb 100644 --- a/modules/admin.js +++ b/modules/admin.js @@ -197,7 +197,7 @@ app.post('/admin/rating/add', async (req, res) => { if (!contest) throw new ErrorMessage('无此比赛'); await contest.loadRelationships(); - const newcalc = await RatingCalculation.create(contest.id); + const newcalc = await RatingCalculation.create({ contest_id: contest.id }); await newcalc.save(); if (!contest.ranklist || contest.ranklist.ranklist.player_num <= 1) { @@ -218,7 +218,12 @@ app.post('/admin/rating/add', async (req, res) => { const user = newRating[i].user; user.rating = newRating[i].currentRating; await user.save(); - const newHistory = await RatingHistory.create(newcalc.id, user.id, newRating[i].currentRating, newRating[i].rank); + const newHistory = await RatingHistory.create({ + rating_calculation_id: newcalc.id, + user_id: user.id, + rating_after: newRating[i].currentRating, + rank: newRating[i].rank + }); await newHistory.save(); } From 04688d7726471a017a64138b3ca8a4cbebbbe4b7 Mon Sep 17 00:00:00 2001 From: hankeke303 Date: Mon, 13 May 2019 22:16:15 +0800 Subject: [PATCH 4/4] fix code unable to be judged in contests --- models/contest_player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/contest_player.ts b/models/contest_player.ts index 686bd5a..2d8ac1b 100644 --- a/models/contest_player.ts +++ b/models/contest_player.ts @@ -22,7 +22,7 @@ export default class ContestPlayer extends Model { @TypeORM.Column({ nullable: true, type: "integer" }) score: number; - @TypeORM.Column({ nullable: true, type: "json" }) + @TypeORM.Column({ default: JSON.stringify({}), type: "json" }) score_details: object; @TypeORM.Column({ nullable: true, type: "integer" })