Skip to content

Commit

Permalink
optimize query
Browse files Browse the repository at this point in the history
  • Loading branch information
leduythuccs committed Dec 5, 2023
1 parent 9c47300 commit 0d5242d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
8 changes: 1 addition & 7 deletions judge/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,7 @@ def get_context_data(self, **kwargs):
get_contest_submission_count(self.object, user.profile,
user.profile.current_contest.virtual), 0)
context['contest_problems'] = Problem.objects.filter(contests__contest=contest_problem.contest) \
.order_by('contests__order').defer('description') \
.annotate(has_public_editorial=Case(
When(solution__is_public=True, solution__publish_on__lte=timezone.now(), then=True),
default=False,
output_field=BooleanField(),
)) \
.add_i18n_name(self.request.LANGUAGE_CODE)
.order_by('contests__order').only('code')

context['available_judges'] = Judge.objects.filter(online=True, problems=self.object)
context['show_languages'] = self.object.allowed_languages.count() != Language.objects.count()
Expand Down
9 changes: 2 additions & 7 deletions templates/problem/problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,9 @@ <h2 style="display: inline-block">{{ title }}</h2>
{% else %}
<td style="text-align: center">
{% endif %}

{% if can_view_all_problems or problem.is_public %}
<a href="{{ url('problem_detail', contest_problem.code) }}">
{{contest.get_label_for_problem(loop.index0)}}
</a>
{% else %}
<a href="{{ url('problem_detail', contest_problem.code) }}">
{{contest.get_label_for_problem(loop.index0)}}
{% endif %}
</a>
</td>
</tr>
{% endfor %}
Expand Down

0 comments on commit 0d5242d

Please sign in to comment.