Browse Source

Merge branch 'master' into monaco-editor

pull/6/head
Menci 6 years ago
parent
commit
344f57e4c2
  1. 11
      models/judge_state.js
  2. 2
      models/problem.js
  3. 2
      models/user.js

11
models/judge_state.js

@ -118,19 +118,16 @@ class JudgeState extends Model {
} }
async updateRelatedInfo(newSubmission) { async updateRelatedInfo(newSubmission) {
await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'problem', this.problem_id], async () => {
await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'user', this.user_id], async () => {
if (this.type === 0) { if (this.type === 0) {
await this.loadRelationships(); await this.loadRelationships();
await this.user.refreshSubmitInfo();
await this.user.save(); // No need to await them.
await this.problem.resetSubmissionCount(); this.user.refreshSubmitInfo();
this.problem.resetSubmissionCount();
} else if (this.type === 1) { } else if (this.type === 1) {
let contest = await Contest.fromID(this.type_info); let contest = await Contest.fromID(this.type_info);
await contest.newSubmission(this); await contest.newSubmission(this);
} }
});
});
} }
async rejudge() { async rejudge() {

2
models/problem.js

@ -490,7 +490,7 @@ class Problem extends Model {
async resetSubmissionCount() { async resetSubmissionCount() {
let JudgeState = syzoj.model('judge_state'); let JudgeState = syzoj.model('judge_state');
await syzoj.utils.lock(['Problem::resetSubmissionCount', this.id], async () => { await syzoj.utils.lock(['Problem::resetSubmissionCount', this.id], async () => {
this.submit_num = await JudgeState.count({ score: { $not: null }, problem_id: this.id, type: { $not: 1 } }); this.submit_num = await JudgeState.count({ problem_id: this.id, type: { $not: 1 } });
this.ac_num = await JudgeState.count({ score: 100, problem_id: this.id, type: { $not: 1 } }); this.ac_num = await JudgeState.count({ score: 100, problem_id: this.id, type: { $not: 1 } });
await this.save(); await this.save();
}); });

2
models/user.js

@ -108,6 +108,8 @@ class User extends Model {
}); });
this.submit_num = cnt; this.submit_num = cnt;
await this.save();
}); });
} }

Loading…
Cancel
Save