From 61fe5675e05c7c324857495c9a4a6dcece2e6107 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 11 Jun 2016 23:43:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=98=E7=9B=AEac=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E5=99=A8=E9=87=8D=E5=A4=8D=E8=AE=A1=E7=AE=97=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/models.py | 4 ++++ judge_dispatcher/tasks.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/account/models.py b/account/models.py index 395ff8d..e91ea3f 100644 --- a/account/models.py +++ b/account/models.py @@ -82,5 +82,9 @@ class UserProfile(models.Model): self.submission_number += 1 self.save(update_fields=["submission_number"]) + def minus_accepted_problem_number(self): + self.accepted_problem_number -= 1 + self.save(update_fields=["accepted_problem_number"]) + class Meta: db_table = "user_profile" diff --git a/judge_dispatcher/tasks.py b/judge_dispatcher/tasks.py index 6f57abc..5fab390 100644 --- a/judge_dispatcher/tasks.py +++ b/judge_dispatcher/tasks.py @@ -138,6 +138,10 @@ class JudgeDispatcher(object): if problems_status["problems"].get(str(problem.id), -1) != 1 and self.submission.result == result["accepted"]: user.userprofile.add_accepted_problem_number() + # 之前状态是ac, 现在不是ac了 需要用户ac题目数量计数器-1, 否则上一个逻辑胡重复增加ac计数器 + if problems_status["problems"].get(str(problem.id), -1) == 1 and self.submission.result != result["accepted"]: + user.userprofile.minus_accepted_problem_number() + if self.submission.result == result["accepted"]: problem.add_ac_number() problems_status["problems"][str(problem.id)] = 1