From 0da30213d42e8ec5067eb598cd0ebffc0cae74a1 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 31 Oct 2024 22:03:28 +0000 Subject: [PATCH 1/4] docker: Update tag This will need to be part of our release procedure going forward. Signed-off-by: Stephen Finucane --- tools/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 0a55b54d..1136d8e4 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/getpatchwork/pyenv:latest +FROM ghcr.io/getpatchwork/pyenv:stable-3.2 ARG UID=1000 ARG GID=1000 From b35f6e3a792d096fc35c8c4168110426581685aa Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Fri, 16 Aug 2024 09:20:28 +0200 Subject: [PATCH 2/4] templates/submission: Fix alignment of commit message Preformatted content must not be indented because any space is kept in the output, making the content wrongly indented. When aligning message headers to the left, the new HTML code has been indented including some preformatted content indented with two spaces. The fix is to remove the indent of the content. Signed-off-by: Thomas Monjalon Fixes: fe34ab2ffad3 ("patch-detail: left align message headers") Reviewed-by: Robin Jarry Reviewed-by: Stephen Finucane (cherry picked from commit 13bbc0d94ea035c149f8acd042d2998778b9efd9) --- patchwork/templates/patchwork/submission.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 85e7be4b..e924934f 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -262,7 +262,7 @@

Message

{{ submission.date }} UTC
-  {{ submission|commentsyntax }}
+{{ submission|commentsyntax }}
   
From 1455a92363500c0128eacc75785eb4aea5fd0015 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 31 Oct 2024 22:14:38 +0000 Subject: [PATCH 3/4] Release 3.2.1 Signed-off-by: Stephen Finucane --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 944880fa..e4604e3a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.2.0 +3.2.1 From 8fa5cc001c663f4017f9b451d2b55b692bc70aa4 Mon Sep 17 00:00:00 2001 From: Tales da Aparecida Date: Mon, 21 Oct 2024 09:14:03 -0300 Subject: [PATCH 4/4] models: optimize with_tag_counts using case-when Leverage PatchTag index replacing the subquery counter with a JOIN. The current code is too slow on MySQL, as it doesn't use indexes. The new approach is more direct and allows proper index usage. Signed-off-by: Tales da Aparecida --- patchwork/models.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/patchwork/models.py b/patchwork/models.py index 4e5afc4b..89ac23bc 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later from collections import Counter -from collections import OrderedDict import datetime import random import re @@ -308,8 +307,6 @@ def with_tag_counts(self, project=None): # Project, and share the project.tags cache between all patch.project # references. qs = self.prefetch_related('project') - select = OrderedDict() - select_params = [] # All projects have the same tags, so we're good to go here if project: @@ -317,16 +314,24 @@ def with_tag_counts(self, project=None): else: tags = Tag.objects.all() + # Annotate the count of each Tag in a column for tag in tags: - select[tag.attr_name] = ( - 'coalesce(' - '(SELECT count FROM patchwork_patchtag' - ' WHERE patchwork_patchtag.patch_id=patchwork_patch.id' - ' AND patchwork_patchtag.tag_id=%s), 0)' + qs = qs.annotate( + **{ + tag.attr_name: models.Sum( + models.Case( + models.When( + patchtag__tag_id=tag.id, + then=models.F('patchtag__count'), + ), + default=models.Value(0), + output_field=models.IntegerField(), + ) + ) + } ) - select_params.append(tag.id) - return qs.extra(select=select, select_params=select_params) + return qs class PatchManager(models.Manager):