Browse Source

Fix wrong submit count of problems

master
Menci 8 years ago
parent
commit
4fa9b64f72
  1. 13
      models/judge_state.js
  2. 2
      modules/problem.js

13
models/judge_state.js

@ -139,14 +139,21 @@ class JudgeState extends Model {
this.result = result;
}
async updateRelatedInfo() {
async updateRelatedInfo(newSubmission) {
if (this.type === 0) {
await this.loadRelationships()
if (newSubmission) {
await this.loadRelationships();
await this.user.refreshSubmitInfo();
this.problem.submit_num++;
if (this.status === 'Accepted') this.problem.ac_num++;
await this.user.save();
await this.problem.save();
} else if (this.status === 'Accepted') {
await this.loadRelationships();
await this.user.refreshSubmitInfo();
this.problem.ac_num++;
await this.user.save();
await this.problem.save();
}
} else if (this.type === 1) {
let contest = await Contest.fromID(this.type_info);
await contest.newSubmission(this);

2
modules/problem.js

@ -232,12 +232,12 @@ app.post('/submit/:id', async (req, res) => {
judge_state.type_info = contest_id;
await judge_state.save();
await judge_state.updateRelatedInfo();
} else {
if (!await problem.isAllowedUseBy(res.locals.user)) throw 'Permission denied.';
judge_state.type = problem.is_public ? 0 : 2;
await judge_state.save();
}
await judge_state.updateRelatedInfo(true);
let waiting_judge = await WaitingJudge.create({
judge_id: judge_state.id

Loading…
Cancel
Save