From: Stewart Smith Date: Fri, 10 Aug 2018 08:01:04 +0000 (+1000) Subject: Optimise fetching checks when displaying a patch X-Git-Tag: v2.2.0-rc1~293 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5c641fc4;p=thirdparty%2Fpatchwork.git Optimise fetching checks when displaying a patch 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 Reviewed-by: Stephen Finucane --- diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 2a28b031..f03e1408 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -218,7 +218,7 @@ function toggle_div(link_id, headers_id) >{{ submission.pull_url }} {% endif %} -{% if submission.checks %} +{% if checks %}

Checks

@@ -226,7 +226,7 @@ function toggle_div(link_id, headers_id) -{% for check in submission.checks %} +{% for check in checks %}
Check Description
{{ check.user }}/{{ check.context }} diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index 03aee09c..0aa9fc65 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -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