mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 16:12:13 +00:00
修复了 submission_number 不变的问题
This commit is contained in:
parent
38f5223444
commit
a0da0b5fa6
@ -85,10 +85,13 @@ class SPJCompiler(DispatcherBase):
|
||||
|
||||
|
||||
class JudgeDispatcher(DispatcherBase):
|
||||
def __init__(self, submission_id, problem_id):
|
||||
def __init__(self, submission_id, problem_id, is_rejudge=False):
|
||||
super().__init__()
|
||||
self.submission = Submission.objects.get(id=submission_id)
|
||||
self.contest_id = self.submission.contest_id
|
||||
self.is_rejudge = is_rejudge
|
||||
self.last_result = None
|
||||
|
||||
if self.contest_id:
|
||||
self.problem = Problem.objects.select_related("contest").get(id=problem_id, contest_id=self.contest_id)
|
||||
self.contest = self.problem.contest
|
||||
@ -119,7 +122,7 @@ class JudgeDispatcher(DispatcherBase):
|
||||
def judge(self):
|
||||
server = self.choose_judge_server()
|
||||
if not server:
|
||||
data = {"submission_id": self.submission.id, "problem_id": self.problem.id}
|
||||
data = {"submission_id": self.submission.id, "problem_id": self.problem.id, "is_rejudge": self.is_rejudge}
|
||||
cache.lpush(CacheKey.waiting_queue, json.dumps(data))
|
||||
return
|
||||
|
||||
@ -150,11 +153,8 @@ 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
|
||||
self.last_result = self.submission.result
|
||||
|
||||
Submission.objects.filter(id=self.submission.id).update(result=JudgeStatus.JUDGING)
|
||||
|
||||
resp = self._request(urljoin(server.service_url, "/judge"), data=data)
|
||||
@ -197,7 +197,7 @@ 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)
|
||||
if not self.last_result:
|
||||
if not self.is_rejudge:
|
||||
problem.submission_number += 1
|
||||
if self.submission.result == JudgeStatus.ACCEPTED:
|
||||
if self.last_result != JudgeStatus.ACCEPTED:
|
||||
|
@ -4,5 +4,5 @@ from judge.dispatcher import JudgeDispatcher
|
||||
|
||||
|
||||
@shared_task
|
||||
def judge_task(submission_id, problem_id):
|
||||
JudgeDispatcher(submission_id, problem_id).judge()
|
||||
def judge_task(submission_id, problem_id, is_rejudge=False):
|
||||
JudgeDispatcher(submission_id, problem_id, is_rejudge=is_rejudge).judge()
|
||||
|
@ -10,15 +10,14 @@ class SubmissionRejudgeAPI(APIView):
|
||||
def get(self, request):
|
||||
id = request.GET.get("id")
|
||||
if not id:
|
||||
return self.error("Paramater error, id is required")
|
||||
return self.error("Parameter error, id is required")
|
||||
try:
|
||||
submission = Submission.objects.select_related("problem").get(id=id, contest_id__isnull=True)
|
||||
except Submission.DoesNotExist:
|
||||
return self.error("Submission does not exists")
|
||||
submission.result = JudgeStatus.PENDING
|
||||
submission.info = {}
|
||||
submission.statistic_info = {}
|
||||
submission.save()
|
||||
|
||||
judge_task.delay(submission.id, submission.problem.id)
|
||||
judge_task.delay(submission.id, submission.problem.id, is_rejudge=True)
|
||||
return self.success()
|
||||
|
Loading…
Reference in New Issue
Block a user