Deprioritize label when archived
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
We need to unprioritize labels when they are archived. See !196443 (comment 2612172874) for more information:
Remove priority when label is archived
It doesn't make sense IMO for an archived label to be a prioritized label, archiving a label should simultaneously remove any prioritization applied as it's essentially out of use. I can see the use case here where you have existing items, but using it for priority seems antithetical to the label being out of use.
This MR makes sure that:
- the priorities are deleted when a label is set to archived.
- it's no longer possible to prioritize archived labels.
It does NOT:
- Change the structure (
All / Archived / Subscribed) of the labels index. I'll do this in a separate MR to keep things small. Afterwards, the view will look a bit more clean again. Right now it can look messy when archived and unarchived labels are mixed inAll, since some can be prioritized and some cannot.
References
Screenshots or screen recordings
How to set up and validate locally
- Enable feature flag via
rails c:
Feature.enable(:labels_archive)
- Archive a label: Go to
Any project > Manage > Labelsand edit a prioritized label in thethree dot dropdown. Check theArchivedcheckbox and save the label. - It should no longer be prioritized.
- You should also see that in the
Alltab archived labels no longer have thestarto prioritize them.
Database Query Plan
I had to manually construct this, as .explain does not directly work on delete_all. Also, this is from my local instance.
Explain
EXPLAIN DELETE FROM "label_priorities" WHERE "label_priorities"."label_id" = 2
Delete on label_priorities (cost=0.15..6.26 rows=0 width=0)
-> Index Scan using index_label_priorities_on_label_id on label_priorities (cost=0.15..6.26 rows=6 width=6)
Index Cond: (label_id = 2)"}
MR acceptance checklist
MR Checklist ( @nwittstruck)
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
Related to #4233
Edited by Nicholas Wittstruck
