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): 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 }}
   
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 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