Loading
Order the user comment templates alphabetically
What does this MR do and why?
This MR implements the first step suggested in #421548 (closed) : sorting the comment templates alphabetically instead of relying on the "random" default order from the database.
It's pretty unobstructive but allows the user to sort their comments by renaming them.
References
Related to #421548 (closed)
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
![]() |
How to set up and validate locally
- Visit any existing issue or MR
- In the comment box, open the comment template picker
- Observe that comment templates are now sorted
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Database change
No indexed use for the sorting, but as users typically have a reasonable number of comment templates, I don't think it's a performance problem.
-
SQL query and plan for user settings pages for comment templates :
- Raw SQL query
SELECT "saved_replies".* FROM "saved_replies" WHERE "saved_replies"."user_id" = 1 ORDER BY LOWER("saved_replies"."name") ASC, "saved_replies"."id" DESC LIMIT 11 - Query plan on dev environment
Limit (cost=4.23..4.24 rows=3 width=128) (actual time=0.041..0.043 rows=4 loops=1) Buffers: shared hit=2 -> Sort (cost=4.23..4.24 rows=3 width=128) (actual time=0.040..0.041 rows=4 loops=1) Sort Key: (lower(name)), id DESC Sort Method: quicksort Memory: 25kB Buffers: shared hit=2 -> Index Scan using index_saved_replies_on_name_text_pattern_ops on saved_replies (cost=0.15..4.21 rows=3 width=128) (actual time=0.0 25..0.028 rows=4 loops=1) Index Cond: (user_id = 1) Buffers: shared hit=2 Planning Time: 0.142 ms Execution Time: 0.066 ms - See https://explain.depesz.com/s/p10I
- Raw SQL query
-
SQL query and plan when opening the comment template picker on a work item :
- Raw SQL query
SELECT "saved_replies".* FROM "saved_replies" WHERE "saved_replies"."user_id" = 1 ORDER BY LOWER("saved_replies"."name") ASC, "saved_replies"."id" DESC LIMIT 101 - Query plan on dev environment
Limit (cost=4.23..4.24 rows=3 width=128) (actual time=0.041..0.043 rows=4 loops=1) Buffers: shared hit=2 -> Sort (cost=4.23..4.24 rows=3 width=128) (actual time=0.040..0.041 rows=4 loops=1) Sort Key: (lower(name)), id DESC Sort Method: quicksort Memory: 25kB Buffers: shared hit=2 -> Index Scan using index_saved_replies_on_name_text_pattern_ops on saved_replies (cost=0.15..4.21 rows=3 width=128) (actual time=0.0 25..0.028 rows=4 loops=1) Index Cond: (user_id = 1) Buffers: shared hit=2 Planning Time: 0.121 ms Execution Time: 0.065 ms - See https://explain.depesz.com/s/eiwL
- Raw SQL query
Edited by Nathanaël Houn

