]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Fetch all series for patch/cover viewing
authorStewart Smith <stewart@linux.ibm.com>
Fri, 10 Aug 2018 08:00:59 +0000 (18:00 +1000)
committerStephen Finucane <stephen@that.guru>
Mon, 10 Sep 2018 20:15:46 +0000 (14:15 -0600)
e.g. a 10 comment patch goes from 26 queries in 17-20ms down to 20
queries in 12ms.

A 67 comment cover letter goes from 14 queries in 16ms down to 8 queries
in 8ms.

So, effectively, a near 2x perf improvement.

Previously, at several points we were asking for the latest series and
then asking for all the series. Since there just usually aren't *that*
many series, fetch them all and take the first one if we need to.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Fix typos in the template and ensure patches from all
 series are shown]
Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/templates/patchwork/submission.html
patchwork/views/cover.py
patchwork/views/patch.py

index 2f69735d69251cedf41f1ec1a0c27068ea0f53b4..2a28b031fee6dae78ede003223d433ebd59509d8 100644 (file)
@@ -64,15 +64,15 @@ function toggle_div(link_id, headers_id)
    </div>
   </td>
  </tr>
-{% if submission.latest_series %}
+{% if all_series %}
  <tr>
   <th>Series</th>
   <td>
    <div class="patchrelations">
     <ul>
-     {% for series in submission.series.all %}
+     {% for series in all_series %}
      <li>
-      {% if series == submission.latest_series %}
+      {% if forloop.first %}
        {{ series }}
       {% else %}
        <a href="{% url 'patch-list' project_id=project.linkname %}?series={{ series.id }}">
@@ -92,8 +92,9 @@ function toggle_div(link_id, headers_id)
       href="javascript:toggle_div('togglepatchrelations', 'patchrelations')"
    >show</a>
    <div id="patchrelations" class="patchrelations" style="display:none;">
+    {% for series in all_series %}
     <ul>
-    {% with submission.latest_series.cover_letter as cover %}
+    {% with series.cover_letter as cover %}
      <li>
      {% if cover %}
       {% if cover == submission %}
@@ -106,7 +107,7 @@ function toggle_div(link_id, headers_id)
      {% endif %}
      </li>
     {% endwith %}
-    {% for sibling in submission.latest_series.patches.all %}
+    {% for sibling in series.patches.all %}
      <li>
       {% if sibling == submission %}
        {{ sibling.name|default:"[no subject]"|truncatechars:100 }}
@@ -118,6 +119,7 @@ function toggle_div(link_id, headers_id)
      </li>
     {% endfor %}
     </ul>
+    {% endfor %}
    </div>
   </td>
  </tr>
index be5db2c215efaa3718d1a7019f475d8262f7833e..62b3d6b2e01a684a46a30b483fdebc9c97d9f989 100644 (file)
@@ -50,6 +50,7 @@ def cover_detail(request, cover_id):
     comments = comments.only('submitter', 'date', 'id', 'content',
                              'submission')
     context['comments'] = comments
+    context['all_series'] = cover.series.all().order_by('-date')
 
     return render(request, 'patchwork/submission.html', context)
 
index e000d0c6e739f0a5e2849dfeac38be8e1327cac0..03aee09c10449dc2acb38d44d5df551f26513f1f 100644 (file)
@@ -119,6 +119,7 @@ def patch_detail(request, patch_id):
                              'submission')
 
     context['comments'] = comments
+    context['all_series'] = patch.series.all().order_by('-date')
     context['submission'] = patch
     context['patchform'] = form
     context['createbundleform'] = createbundleform