Optimize exam collection queries by annotating exam counts and prefetching authors to improve template performance
This commit is contained in:
@@ -27,12 +27,10 @@
|
||||
<span class="badge bg-secondary" title="Archived">Archived</span>
|
||||
{% endif %}
|
||||
|
||||
{# Total exams count (sum of known related exam sets) #}
|
||||
{% with a=collection.anatomy_exams.count l=collection.longs_exams.count p=collection.physics_exams.count r=collection.rapids_exams.count s=collection.sbas_exams.count %}
|
||||
{% with total=a|add:l|add:p|add:r|add:s %}
|
||||
<span class="badge bg-info text-dark ms-1" title="Total exams">{{ total }} exams</span>
|
||||
{% endwith %}
|
||||
{# Per-type badges (only show non-zero) #}
|
||||
{# Use annotated counts provided by the view to avoid per-card COUNT queries #}
|
||||
<span class="badge bg-info text-dark ms-1" title="Total exams">{{ collection.total_count }} exams</span>
|
||||
{# Per-type badges (only show non-zero) #}
|
||||
{% with a=collection.anatomy_count l=collection.longs_count p=collection.physics_count r=collection.rapids_count s=collection.sbas_count %}
|
||||
{% if a %}<span class="badge bg-primary ms-1">Anatomy {{ a }}</span>{% endif %}
|
||||
{% if l %}<span class="badge bg-primary ms-1">Longs {{ l }}</span>{% endif %}
|
||||
{% if p %}<span class="badge bg-primary ms-1">Physics {{ p }}</span>{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user