fix rejudge bug

This commit is contained in:
xudian 2018-03-14 11:55:08 +08:00
parent 0e83a920b2
commit 86f995d23c

View File

@ -150,7 +150,11 @@ class JudgeDispatcher(DispatcherBase):
"spj_compile_config": spj_config.get("compile"),
"spj_src": self.problem.spj_code
}
self.last_result = None
try:
self.last_result = Submission.objects.get(id=self.submission.id).result
except Submission.DoesNotExist:
pass
Submission.objects.filter(id=self.submission.id).update(result=JudgeStatus.JUDGING)
resp = self._request(urljoin(server.service_url, "/judge"), data=data)
@ -193,9 +197,14 @@ class JudgeDispatcher(DispatcherBase):
with transaction.atomic():
# update problem status
problem = Problem.objects.select_for_update().get(contest_id=self.contest_id, id=self.problem.id)
problem.submission_number += 1
if not self.last_result:
problem.submission_number += 1
if self.submission.result == JudgeStatus.ACCEPTED:
problem.accepted_number += 1
if self.last_result != JudgeStatus.ACCEPTED:
problem.accepted_number += 1
else:
if self.last_result == JudgeStatus.ACCEPTED:
problem.accepted_number -= 1
problem_info = problem.statistic_info
problem_info[result] = problem_info.get(result, 0) + 1
problem.save(update_fields=["accepted_number", "submission_number", "statistic_info"])