Add ability to search for escalation policies by name
What does this MR do and why?
Related issue: #330284 (closed)
What
This MR adds a name
argument in GraphQL to the project.escalation_policies
field, which allows a caller to provide a string to search through escalation policies.
Why
This change is needed in order to easily take advantage of SidebarDropdownWidget
shared component on the frontend. Incident issues will have an Escalation policy
dropdown in the sidebar which works similarly to milestones/iterations/etc.
At the moment, the usefulness of this new search argument is limited, however, as only one escalation policy is available on each project. We plan to allow more in future, though - &4924.
database info
SupplementalSQL
SELECT "incident_management_escalation_policies".*
FROM "incident_management_escalation_policies"
WHERE "incident_management_escalation_policies"."project_id" = 21
AND "incident_management_escalation_policies"."name" ILIKE '%policy%'
ORDER BY "incident_management_escalation_policies"."id" DESC
LIMIT 100
Query plan
This new query uses existing indices, and as there's also very limited data in the table on dot-com, performance is snappy.
Output from database-lab run: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/8251/commands/29239
Limit (cost=3.30..3.31 rows=1 width=64) (actual time=0.062..0.064 rows=1 loops=1)
Buffers: shared hit=9
I/O Timings: read=0.000 write=0.000
-> Sort (cost=3.30..3.31 rows=1 width=64) (actual time=0.061..0.062 rows=1 loops=1)
Sort Key: incident_management_escalation_policies.id DESC
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=9
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_on_project_id_escalation_policy_name_unique on public.incident_management_escalation_policies (cost=0.27..3.29 rows=1 width=64) (actual time=0.031..0.032 rows=1 loops=1)
Index Cond: (incident_management_escalation_policies.project_id = 278964)
Filter: (incident_management_escalation_policies.name ~~* '%policy%'::text)
Rows Removed by Filter: 0
Buffers: shared hit=6
I/O Timings: read=0.000 write=0.000
Time: 0.292 ms
- planning: 0.202 ms
- execution: 0.090 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 9 (~72.00 KiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
Screenshots
GraphQL query&response w/o search term | w/ matching search term | w/ non-matching search term |
---|---|---|
How to set up and validate locally
-
Prereq: have a user in a project with GitLab Premium+ with maintainer+ permissions
-
Create an escalation policy in the project (
Monitor > Escalation Policies
) -
Open the
/-/graphql-explorer
route to test with queries, like this sample:query projectPolicies { project(fullPath: "root/autodevops") { incidentManagementEscalationPolicies(name: "Bad search") { nodes { id name } } } }
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.