Skip to content

Add labels support - #669

Open
fstachura wants to merge 17 commits into
getpatchwork:mainfrom
fstachura:labels_m2m_final
Open

Add labels support#669
fstachura wants to merge 17 commits into
getpatchwork:mainfrom
fstachura:labels_m2m_final

Conversation

@fstachura

Copy link
Copy Markdown

This series is a continuation of labels series published by Stephen Finucane
back in 2018.

Changes since v2:

  • Implemented a command for relabeling existing patches
  • Added a labels filter with autocomplete
  • Added a labels filter to the API
  • Updated selectize to the latest version

I have started implementing series -> patch labels inheritance. It's not
included in this series as I'm not sure how it should work. As I understand
it, the name of the series may be changed as new patches are parsed.
I'm also not sure where in the UI users could see/modify labels for series.

This version uses a many-to-many relation for storing labels assigned to a
patch, like in v2. I understand that there is a performance concern as this
could cause excessive JOINs in queries. From what I can see, Django only uses
JOINs when patches are filtered by labels. When patches are just listed without
any filters, a separate query to the patch-labels table is executed instead
of a JOIN, that query seems to be rather cheap.

I have a POC alternative version that uses JSON columns to store an array with
labels inside the patches table.

So far it's not obvious to me that the JSON version is better performance-wise
(in my tests it sometimes was, sometimes not, especially on MySQL, that could be
an issue with my setup or the tests). Downsides: the code is more complex,
and I think there may be some issues around update atomicity.

Some of the commits from v2 were modified beyond just rebase and formatting.
I have retained the original author, unless the changes were really significant.
I'm submitting these patches now, I have added myself to Signed-off-by.
I'm not sure if this is 100% OK, so please let me know.

Sponsored-By: The Linux Foundation
Closes: #22

stephenfin and others added 17 commits July 31, 2026 14:43
This will allow us to store color codes cleanly in the database.
Labels are arbitrary bits of metadata attached to a submission. They can
be used to signify priority, category, or other similar information.
They can also be used to filter patches and identify the ones most
interesting to a given user.

Labels can be associated with a project to ensure that one project can
use a totally different set of labels to another and to, in the future,
allow a project administrator to use their own labels. However, they can
also be global, which is useful for things that would be common across
multiple projects such as "RFC".
Extend the parser to strip the label from the list of prefixes. This
means we don't duplicate things twice in the UI.
There are two added: a general labels view that includes both project
and non-project labels, and an inline labels view that's part of the
project.
This is required to ensure we can filter delegates by project. If we
don't do this, our <select> gets stupid long, as seen in commit
198139e.
Nothing too complicated here. The forms we have for this need some
serious cleanup/beautification, but that's a problem for another day.
One extra query is necessary for patch/cover endpoints to fetch labels
information.
The filter allows filtering by project-specific and global labels.
It also supports negative filtering. Prepending a label name with
a minus sign excludes patches with that label from search results.
Patches in the API can be filtered by labels using the 'labels'
query parameter.
a741c95 upgraded selectize to 0.13.5. However, it looks like a
non-standalone version was uploaded by accident. On page load, the
following error can be seen in debug console: "Selectize: Dependency
MicroPlugin is missing".

Because of that, the submitter autocomplete no longer works.

Version 0.13.5 was not released on Github, so I have decided to upgrade
the library to the latest available version.

Add updated files to .gitattributes to skip them in patches.
Selectize in Patchwork was broken for quite a long time and nobody
missed it enough to report a bug. So it's likely that most Patchwork
users are expecting the Submitter field to work with partial search by
default. Fixing selectize breaks this, as it will force the first
matching autocomplete option as the searched submitter on enter/blur.
Previously not all users were happy with autocomplete, for example see:
https://lists.ozlabs.org/pipermail/patchwork/2015-August/001442.html

This commit partially reverts back to the old behaviour. The default
autocomplete option is now exactly what is typed in the input field.

This is still not fully compatible with the old behaviour, users that
want to search just by submitter will have to press enter twice, first
to "create" the option, second to submit the search.
I have decided to render all labels into the html instead of
requesting them through the API. I'm assuming that there won't be that
many different labels for a project, so I went with the simpler
approach.
This commit adds autocomplete similar to the filter autocomplete
to labels field in patch details view (for users with project admin
rights).
The command re-parses subject headers of patches from given projects
and adds label information to the database. The main usecase is to
refresh label information on existing patches after adding a new label
to the project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Labels

2 participants