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); 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" }) 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(); } 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 }); }