diff --git a/account/models.py b/account/models.py index 395ff8df..e91ea3fd 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 6f57abcf..5fab390f 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