Skip to content

Commit eb90318

Browse files
authored
Merge pull request #7015 from escattone/improve-question-details-2623
fix N+1 query issue in `question.details`
2 parents 9f478b1 + 128de34 commit eb90318

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kitsune/questions/jinja2/questions/question_details.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ <h3 class="sumo-card-heading">{{ _('Post a Reply') }}</h3>
396396
<li class="sidebar-subheading sidebar-nav--heading-item">{{ _('Tags') }}</li>
397397
<li id="tags-list">
398398
<div class="folder">
399-
{% set tags = question.my_tags %}
400399
{% if tags or can_tag %}
401400
<div class="sidebox tight cf" id="tags">
402401
<div class="tags"{% if can_tag %} data-tag-vocab-json="{{ tag_vocab() }}"{% endif %}>
@@ -413,7 +412,7 @@ <h3 class="sumo-card-heading">{{ _('Post a Reply') }}</h3>
413412
{% for tag in all_tags %}
414413
<option value="{{ tag.id }}"
415414
data-url="{{ url('questions.list', product.slug if product else 'all')|urlparams(tagged=tag.slug) }}"
416-
{% if tag in question.tags.all() %}selected{% endif %}>
415+
{% if tag.id in tag_ids %}selected{% endif %}>
417416
{{ tag.name }}
418417
</option>
419418
{% endfor %}

kitsune/questions/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,9 @@ def _answers_data(request, question_id, form=None, watch_form=None, answer_previ
15471547
QuestionReplyEvent.is_notifying(request.user, question)
15481548
or QuestionSolvedEvent.is_notifying(request.user, question)
15491549
)
1550+
1551+
tags = question.my_tags
1552+
15501553
return {
15511554
"question": question,
15521555
"product": question.product,
@@ -1558,6 +1561,8 @@ def _answers_data(request, question_id, form=None, watch_form=None, answer_previ
15581561
"feeds": feed_urls,
15591562
"frequencies": frequencies,
15601563
"is_watching_question": is_watching_question,
1564+
"tags": tags,
1565+
"tag_ids": {t.id for t in tags},
15611566
"can_tag": request.user.has_perm("questions.tag_question"),
15621567
"can_create_tags": request.user.has_perm("taggit.add_tag"),
15631568
}

0 commit comments

Comments
 (0)