From fee687dc3b6ad9603950a861957528ca3e5130c6 Mon Sep 17 00:00:00 2001 From: Menci Date: Tue, 13 Jun 2017 10:20:34 +0800 Subject: [PATCH] Fix user ac_num not updated --- models/judge_state.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/models/judge_state.js b/models/judge_state.js index 1fa27d0..3e336b0 100644 --- a/models/judge_state.js +++ b/models/judge_state.js @@ -186,6 +186,12 @@ class JudgeState extends Model { } else if (this.type === 1) { let contest = await Contest.fromID(this.type_info); await contest.newSubmission(this); + } else if (this.type === 2) { + if (newSubmission || this.status === 'Accepted') { + await this.loadRelationships(); + await this.user.refreshSubmitInfo(); + await this.user.save(); + } } } @@ -209,14 +215,16 @@ class JudgeState extends Model { await waiting_judge.save(); + if (oldStatus === 'Accepted') { + await this.user.refreshSubmitInfo(); + await this.user.save(); + } + if (this.type === 0) { if (oldStatus === 'Accepted') { this.problem.ac_num--; - await this.user.refreshSubmitInfo(); - await this.user.save(); + await this.problem.save(); } - - await this.problem.save(); } else if (this.type === 1) { let contest = await Contest.fromID(this.type_info); await contest.newSubmission(this);