Browse Source

Merge pull request #133 from hankeke303/master

Fix some contests bugs
master
Menci 6 years ago committed by GitHub
parent
commit
fe1ea9eb2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      models/contest.ts
  2. 2
      models/contest_player.ts
  3. 9
      modules/admin.js
  4. 4
      modules/problem.js

1
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);

2
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" })

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

4
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
});
}

Loading…
Cancel
Save