]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Optimise fetching checks when displaying a patch
authorStewart Smith <stewart@linux.ibm.com>
Fri, 10 Aug 2018 08:01:04 +0000 (18:01 +1000)
committerStephen Finucane <stephen@that.guru>
Mon, 10 Sep 2018 20:24:24 +0000 (14:24 -0600)
Prior to this patch, a typical /patch// query for linuxppc-dev
(which has about half a dozen checks per patch) took around 20 queries
and 16.5ms in the database. About half of those queries were fetching
the checks and who did the check.

We can just do one query to get all that needed information, so we do
that. This brings a page load down to 10 queries in 12ms.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/templates/patchwork/submission.html
patchwork/views/patch.py

index 2a28b031fee6dae78ede003223d433ebd59509d8..f03e14084b3634c0ab669aeede0ec71ae4ce3b86 100644 (file)
@@ -218,7 +218,7 @@ function toggle_div(link_id, headers_id)
  >{{ submission.pull_url }}</a>
 {% endif %}
 
-{% if submission.checks %}
+{% if checks %}
 <h2>Checks</h2>
 <table class="checks">
 <tr>
@@ -226,7 +226,7 @@ function toggle_div(link_id, headers_id)
   <th>Check</th>
   <th>Description</th>
 </tr>
-{% for check in submission.checks %}
+{% for check in checks %}
 <tr>
   <td>{{ check.user }}/{{ check.context }}</td>
   <td>
index 03aee09c10449dc2acb38d44d5df551f26513f1f..0aa9fc656cf8226c0af01efff974665a2c2d900e 100644 (file)
@@ -120,6 +120,7 @@ def patch_detail(request, patch_id):
 
     context['comments'] = comments
     context['all_series'] = patch.series.all().order_by('-date')
+    context['checks'] = patch.check_set.all().select_related('user')
     context['submission'] = patch
     context['patchform'] = form
     context['createbundleform'] = createbundleform