Browse Source

Lock on JudgeState::updateRelatedInfo

pull/6/head
Menci 7 years ago
parent
commit
15e66065cd
  1. 40
      models/judge_state.js

40
models/judge_state.js

@ -173,24 +173,28 @@ class JudgeState extends Model {
} }
async updateRelatedInfo(newSubmission) { async updateRelatedInfo(newSubmission) {
if (this.type === 0) { await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'problem', this.problem_id], async () => {
if (newSubmission) { await syzoj.utils.lock(['JudgeState::updateRelatedInfo', 'user', this.user_id], async () => {
await this.loadRelationships(); if (this.type === 0) {
await this.user.refreshSubmitInfo(); if (newSubmission) {
this.problem.submit_num++; await this.loadRelationships();
await this.user.save(); await this.user.refreshSubmitInfo();
await this.problem.save(); this.problem.submit_num++;
} else if (this.status === 'Accepted') { await this.user.save();
await this.loadRelationships(); await this.problem.save();
await this.user.refreshSubmitInfo(); } else if (this.status === 'Accepted') {
this.problem.ac_num++; await this.loadRelationships();
await this.user.save(); await this.user.refreshSubmitInfo();
await this.problem.save(); this.problem.ac_num++;
} await this.user.save();
} else if (this.type === 1) { await this.problem.save();
let contest = await Contest.fromID(this.type_info); }
await contest.newSubmission(this); } else if (this.type === 1) {
} let contest = await Contest.fromID(this.type_info);
await contest.newSubmission(this);
}
});
});
} }
async rejudge() { async rejudge() {

Loading…
Cancel
Save