From 2e46aa9ec3dea42942012e6ed8c48276249719a8 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Fri, 10 Aug 2018 18:00:59 +1000 Subject: [PATCH] Fetch all series for patch/cover viewing 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 [stephenfin: Fix typos in the template and ensure patches from all series are shown] Signed-off-by: Stephen Finucane --- patchwork/templates/patchwork/submission.html | 12 +++++++----- patchwork/views/cover.py | 1 + patchwork/views/patch.py | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 2f69735d..2a28b031 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -64,15 +64,15 @@ function toggle_div(link_id, headers_id) -{% if submission.latest_series %} +{% if all_series %} Series
    - {% for series in submission.series.all %} + {% for series in all_series %}
  • - {% if series == submission.latest_series %} + {% if forloop.first %} {{ series }} {% else %} @@ -92,8 +92,9 @@ function toggle_div(link_id, headers_id) href="javascript:toggle_div('togglepatchrelations', 'patchrelations')" >show diff --git a/patchwork/views/cover.py b/patchwork/views/cover.py index be5db2c2..62b3d6b2 100644 --- a/patchwork/views/cover.py +++ b/patchwork/views/cover.py @@ -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) diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index e000d0c6..03aee09c 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -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 -- 2.47.3