From 7cf1df266e78da730e5ef2f7ef32811fe705d9a1 Mon Sep 17 00:00:00 2001 From: "sxw@401" Date: Sat, 5 Sep 2015 16:47:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E6=96=87=E4=BB=B6=E8=BF=87?= =?UTF-8?q?=E5=A4=A7=E6=97=B6=E5=BC=95=E5=8F=91memoryERROR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problem/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/problem/views.py b/problem/views.py index 2e9d172..a295ad1 100644 --- a/problem/views.py +++ b/problem/views.py @@ -185,8 +185,12 @@ class TestCaseUploadAPIView(APIView): os.mkdir(test_case_dir) for name in l: f = open(test_case_dir + name, "wb") - f.write(test_case_file.read(name).replace("\r\n", "\n")) - f.close() + try: + f.write(test_case_file.read(name).replace("\r\n", "\n")) + except MemoryError: + return error_response(u"单个测试数据体积过大!") + finally: + f.close() l.sort() file_info = {"test_case_number": len(l) / 2, "test_cases": {}} From 152d949a147cfeb876b3ed007384202bbc48cc66 Mon Sep 17 00:00:00 2001 From: "sxw@401" Date: Sat, 5 Sep 2015 18:27:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86rank=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=80=BB=E6=8F=90=E4=BA=A4=E6=95=B0=E7=9A=84=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/oj/contest/contest_rank.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/src/oj/contest/contest_rank.html b/template/src/oj/contest/contest_rank.html index 823b021..43c5444 100644 --- a/template/src/oj/contest/contest_rank.html +++ b/template/src/oj/contest/contest_rank.html @@ -38,7 +38,7 @@ {{ forloop.counter }} {{ item.user.username }} - {{ item.total_ac }} / {{ item.total_submit }} + {{ item.total_ac }} / {{ item.total_submission_number }} {% if item.total_time %}{{ item.total_time }} min{% else %}--{% endif %} {% for problem in contest_problems %} From c163103542e87fb616df2d5b804854eeff2c5ea0 Mon Sep 17 00:00:00 2001 From: "sxw@401" Date: Sat, 5 Sep 2015 18:54:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=E6=8E=92=E5=90=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contest/views.py | 2 +- template/src/oj/contest/contest_rank.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contest/views.py b/contest/views.py index e23b50e..91aa8f7 100644 --- a/contest/views.py +++ b/contest/views.py @@ -396,7 +396,7 @@ def _cmp(x, y): def contest_rank_page(request, contest_id): contest = Contest.objects.get(id=contest_id) contest_problems = ContestProblem.objects.filter(contest=contest).order_by("sort_index") - result = ContestSubmission.objects.values("user_id").annotate(total_submit=Count("user_id")) + result = ContestSubmission.objects.values("user_id").annotate(total_submit=Sum("total_submission_number")) for i in range(0, len(result)): # 这个人所有的提交 submissions = ContestSubmission.objects.filter(user_id=result[i]["user_id"]) diff --git a/template/src/oj/contest/contest_rank.html b/template/src/oj/contest/contest_rank.html index 43c5444..823b021 100644 --- a/template/src/oj/contest/contest_rank.html +++ b/template/src/oj/contest/contest_rank.html @@ -38,7 +38,7 @@ {{ forloop.counter }} {{ item.user.username }} - {{ item.total_ac }} / {{ item.total_submission_number }} + {{ item.total_ac }} / {{ item.total_submit }} {% if item.total_time %}{{ item.total_time }} min{% else %}--{% endif %} {% for problem in contest_problems %}