Skip to content

Add scope to escalation policy model and update model specs

Kristen Cutler requested to merge 361313-scope-escalation-policies-name into master

What does this MR do and why?

This MR replaces the escalation policy model find_by_name method with a scope. It also adds a by_exact_name method to the escalation policy finder to use the new scope. Reference the following comments for context, !85901 (comment 928206850) and !79977 (comment 927614668).

Query and plan for existing method:

SELECT
    "incident_management_escalation_policies".*
FROM
    "incident_management_escalation_policies"
WHERE
    "incident_management_escalation_policies"."project_id" = 1
    AND (LOWER(name) = 'another escalation policy')
LIMIT 1
 Limit  (cost=0.27..3.30 rows=1 width=60) (actual time=0.075..0.075 rows=1 loops=1)
   Buffers: shared hit=6
   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.30 rows=1 width=60) (actual time=0.073..0.073 rows=1 loops=1)
         Index Cond: (incident_management_escalation_policies.project_id = 278964)
         Filter: (lower(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

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13625/commands/47854#visualize-depesz

Query and plan for scope:

SELECT
    "incident_management_escalation_policies".*
FROM
    "incident_management_escalation_policies"
WHERE
    "incident_management_escalation_policies"."project_id" = 1
    AND (LOWER(name) = 'another escalation policy')
ORDER BY
    "incident_management_escalation_policies"."id" ASC
LIMIT 1
 Limit  (cost=3.31..3.31 rows=1 width=60) (actual time=0.102..0.103 rows=1 loops=1)
   Buffers: shared hit=9
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=3.31..3.31 rows=1 width=60) (actual time=0.100..0.101 rows=1 loops=1)
         Sort Key: incident_management_escalation_policies.id
         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.30 rows=1 width=60) (actual time=0.060..0.060 rows=1 loops=1)
               Index Cond: (incident_management_escalation_policies.project_id = 278964)
               Filter: (lower(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

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13625/commands/47855#visualize-depesz

How to set up and validate locally

In a GitLab Premium project with maintainer permissions:

  1. Add an on-call schedule and escalation policy in the UI.
  2. Create a new issue of type incident.
  3. Type /page <escalation policy name from step 1> as a comment.
  4. Check flash messages and system notes when escalation is triggered.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #361313 (closed)

Edited by Kristen Cutler

Merge request reports

Loading