Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions patchwork/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -308,25 +307,31 @@ 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:
tags = project.tags
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):
Expand Down
2 changes: 1 addition & 1 deletion patchwork/templates/patchwork/submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ <h2>Message</h2>
<span class="message-date">{{ submission.date }} UTC</span>
</div>
<pre class="content">
{{ submission|commentsyntax }}
{{ submission|commentsyntax }}
</pre>
</div>

Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/getpatchwork/pyenv:latest
FROM ghcr.io/getpatchwork/pyenv:stable-3.2

ARG UID=1000
ARG GID=1000
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0
3.2.1