From 44d094f19ca6eca596fa37c36c9c1e7d90e18f7f Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Thu, 24 Sep 2015 15:28:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E9=A2=98?= =?UTF-8?q?=E7=9B=AE=20ac=20=E7=8A=B6=E6=80=81=E7=9A=84=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contest/views.py | 12 ------------ mq/scripts/mq.py | 5 +++++ problem/views.py | 6 +----- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/contest/views.py b/contest/views.py index 8e0a2ac4..ccf2c953 100644 --- a/contest/views.py +++ b/contest/views.py @@ -334,18 +334,6 @@ def contest_problems_list_page(request, contest_id): """ contest = Contest.objects.get(id=contest_id) contest_problems = ContestProblem.objects.filter(contest=contest).order_by("sort_index") - submissions = ContestSubmission.objects.filter(user=request.user, contest=contest) - state = {} - for item in submissions: - state[item.problem_id] = item.ac - for item in contest_problems: - if item.id in state: - if state[item.id]: - item.state = 1 - else: - item.state = 2 - else: - item.state = 0 return render(request, "oj/contest/contest_problems_list.html", {"contest_problems": contest_problems, "contest": {"id": contest_id}}) diff --git a/mq/scripts/mq.py b/mq/scripts/mq.py index caae75ee..47231da1 100644 --- a/mq/scripts/mq.py +++ b/mq/scripts/mq.py @@ -82,5 +82,10 @@ class MessageQueue(object): contest_problem.total_accepted_number += 1 contest_problem.save() + problems_status = user.problems_status + problems_status["contest_problems"][str(contest_problem.id)] = 1 + user.problems_status = problems_status + user.save() + logger.debug("Start message queue") MessageQueue().listen_task() diff --git a/problem/views.py b/problem/views.py index 8dc42d63..3b74ec2b 100644 --- a/problem/views.py +++ b/problem/views.py @@ -305,15 +305,11 @@ def problem_list_page(request, page=1): except Exception: pass - if request.user.is_authenticated(): - problems_status = json.loads(request.user.problems_status) - else: - problems_status = {} # 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的 tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number") return render(request, "oj/problem/problem_list.html", {"problems": current_page, "page": int(page), "previous_page": previous_page, "next_page": next_page, - "keyword": keyword, "tag": tag_text,"problems_status": problems_status, + "keyword": keyword, "tag": tag_text, "tags": tags, "difficulty_order": difficulty_order})