diff --git a/submission/views.py b/submission/views.py index 984cb724..19f3c292 100644 --- a/submission/views.py +++ b/submission/views.py @@ -165,6 +165,16 @@ def my_submission_list_page(request, page=1): if result: submissions = submissions.filter(result=int(result)) filter = {"name": "result", "content": result} + + # 为 submission 查询题目 因为提交页面经常会有重复的题目,缓存一下查询结果 + cache_result = {} + for item in submissions: + problem_id = item["problem_id"] + if problem_id not in cache_result: + problem = Problem.objects.get(id=problem_id) + cache_result[problem_id] = problem.title + item["title"] = cache_result[problem_id] + paginator = Paginator(submissions, 20) try: current_page = paginator.page(int(page)) diff --git a/template/src/oj/problem/my_submissions_list.html b/template/src/oj/problem/my_submissions_list.html deleted file mode 100644 index 3bf7ac5f..00000000 --- a/template/src/oj/problem/my_submissions_list.html +++ /dev/null @@ -1,52 +0,0 @@ -{% extends 'oj_base.html' %} - -{% block body %} - - {% load submission %} -
- - {% include "oj/problem/_problem_header.html" %} - {% if submissions %} - - - - - - - - - - - - {% for item in submissions %} - - - - - - - - {% endfor %} - - -
#提交时间语言运行时间结果
{{ forloop.counter }}{{ item.create_time }} - {{ item.language|translate_language }} - - {% if item.accepted_answer_time %} - {{ item.accepted_answer_time }}ms - {% else %} - -- - {% endif %} - - {{ item.result|translate_result }} -
- {% else %} -

你还没有提交该题目

- {% endif %} -
-{% endblock %} \ No newline at end of file diff --git a/template/src/oj/submission/my_submissions_list.html b/template/src/oj/submission/my_submissions_list.html index 08cf17d2..6df28eb0 100644 --- a/template/src/oj/submission/my_submissions_list.html +++ b/template/src/oj/submission/my_submissions_list.html @@ -52,7 +52,7 @@ {{ forloop.counter |add:start_id }} - {{ item.problem_id }} + {{ item.title }} {{ item.create_time }}