mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-01 10:02:01 +00:00
修复problem统计错误
This commit is contained in:
parent
1587192ff9
commit
57b75fd511
@ -25,7 +25,7 @@ def process_pending_task():
|
||||
if judge_cache.llen(CacheKey.waiting_queue):
|
||||
# 防止循环引入
|
||||
from judge.tasks import judge_task
|
||||
data = json.loads(judge_cache.rpop(CacheKey.waiting_queue))
|
||||
data = json.loads(judge_cache.rpop(CacheKey.waiting_queue).decode("utf-8"))
|
||||
judge_task.delay(**data)
|
||||
|
||||
|
||||
@ -148,7 +148,8 @@ class JudgeDispatcher(object):
|
||||
else:
|
||||
problem = Problem.objects.select_related().get(_id=self.problem.id)
|
||||
info = problem.statistic_info
|
||||
info[self.submission.result] = info.get(self.submission.result, 0) + 1
|
||||
result = str(self.submission.result)
|
||||
info[result] = info.get(result, 0) + 1
|
||||
problem.statistic_info = info
|
||||
problem.save(update_fields=["statistic_info"])
|
||||
|
||||
|
@ -83,6 +83,7 @@ class ProblemSerializer(serializers.ModelSerializer):
|
||||
create_time = DateTimeTZField()
|
||||
last_update_time = DateTimeTZField()
|
||||
created_by = UsernameSerializer()
|
||||
statistic_info = serializers.JSONField()
|
||||
|
||||
class Meta:
|
||||
model = Problem
|
||||
@ -97,6 +98,7 @@ class ContestProblemSerializer(serializers.ModelSerializer):
|
||||
create_time = DateTimeTZField()
|
||||
last_update_time = DateTimeTZField()
|
||||
created_by = UsernameSerializer()
|
||||
statistic_info = serializers.JSONField()
|
||||
|
||||
class Meta:
|
||||
model = ContestProblem
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
from account.decorators import login_required, check_contest_permission
|
||||
from judge.tasks import judge_task
|
||||
# from judge.dispatcher import JudgeDispatcher
|
||||
from problem.models import Problem, ProblemRuleType, ContestProblem
|
||||
from contest.models import Contest, ContestStatus
|
||||
from utils.api import APIView, validate_serializer
|
||||
@ -11,9 +12,6 @@ from ..serializers import SubmissionSafeSerializer, SubmissionListSerializer
|
||||
from utils.cache import throttling_cache
|
||||
|
||||
|
||||
# from judge.dispatcher import JudgeDispatcher
|
||||
|
||||
|
||||
def _submit(response, user, problem_id, language, code, contest_id):
|
||||
# TODO: 预设默认值,需修改
|
||||
controller = BucketController(user_id=user.id,
|
||||
|
Loading…
Reference in New Issue
Block a user