Add severity and published sorting for incidents
What does this MR do?
ActiveRecord scopes (using https://gitlab.com/gitlab-org/monitor/monitor-sandbox as it has incident issues):
Issue.order_severity_asc / Issue.order_severity_desc
:
The usecase for this tom be used is:
- filtered by
issue_type
=incident
- filtered by project
Below is an example targeting https://gitlab.com/gitlab-org/monitor/monitor-sandbox.
SELECT "issues".*, "issuable_severities".* FROM "issues" LEFT OUTER JOIN "issuable_severities" ON "issuable_severities"."issue_id" = "issues"."id" WHERE "issues"."project_id" = 12507547 AND "issues"."issue_type" = 1 ORDER BY issuable_severities.severity ASC, "issues"."id" ASC NULLS FIRST LIMIT 100
Issue.order_status_page_published_first
(EE only):
SELECT “issues”.“id” AS t0_r0, “issues”.“title” AS t0_r1, “issues”.“author_id” AS t0_r2, “issues”.“project_id” AS t0_r3, “issues”.“created_at” AS t0_r4, “issues”.“updated_at” AS t0_r5, “issues”.“description” AS t0_r6, “issues”.“milestone_id” AS t0_r7, “issues”.“iid” AS t0_r8, “issues”.“updated_by_id” AS t0_r9, “issues”.“weight” AS t0_r10, “issues”.“confidential” AS t0_r11, “issues”.“due_date” AS t0_r12, “issues”.“moved_to_id” AS t0_r13, “issues”.“lock_version” AS t0_r14, “issues”.“title_html” AS t0_r15, “issues”.“description_html” AS t0_r16, “issues”.“time_estimate” AS t0_r17, “issues”.“relative_position” AS t0_r18, “issues”.“service_desk_reply_to” AS t0_r19, “issues”.“cached_markdown_version” AS t0_r20, “issues”.“last_edited_at” AS t0_r21, “issues”.“last_edited_by_id” AS t0_r22, “issues”.“discussion_locked” AS t0_r23, “issues”.“closed_at” AS t0_r24, “issues”.“closed_by_id” AS t0_r25, “issues”.“state_id” AS t0_r26, “issues”.“duplicated_to_id” AS t0_r27, “issues”.“promoted_to_epic_id” AS t0_r28, “issues”.“health_status” AS t0_r29, “issues”.“external_key” AS t0_r30, “issues”.“sprint_id” AS t0_r31, “issues”.“issue_type” AS t0_r32, “issues”.“blocking_issues_count” AS t0_r33, “status_page_published_incidents”.“id” AS t1_r0, “status_page_published_incidents”.“created_at” AS t1_r1, “status_page_published_incidents”.“updated_at” AS t1_r2, “status_page_published_incidents”.“issue_id” AS t1_r3 FROM “issues” LEFT OUTER JOIN “status_page_published_incidents” ON “status_page_published_incidents”.“issue_id” = “issues”.“id” WHERE “issues”.“project_id” = 12507547
ORDER BY status_page_published_incidents.id ASC NULLS LAST LIMIT 100
Example GraphQL Queries:
{
project(fullPath: "root/autodevops-deploy-test") {
id
issues(sort: SEVERITY_ASC, types: [INCIDENT]) {
nodes {
title
severity
}
}
}
}
Result:
{
"data": {
"project": {
"id": "gid://gitlab/Project/21",
"issues": {
"nodes": [
{
"title": "Test new error",
"severity": "LOW"
},
{
"title": "Test new error",
"severity": "HIGH"
}
]
}
}
}
}
{
project(fullPath: "root/autodevops-deploy-test") {
id
issues(sort: PUBLISHED_ASC, types: [INCIDENT]) {
nodes {
title
severity
statusPagePublishedIncident
}
}
}
}
Result:
{
"data": {
"project": {
"id": "gid://gitlab/Project/21",
"issues": {
"nodes": [
{
"title": "Test new error",
"severity": "LOW",
"statusPagePublishedIncident": null
},
{
"title": "Test new error",
"severity": "HIGH",
"statusPagePublishedIncident": true
}
]
}
}
}
}
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Refs #229534 (closed)
Edited by Sean Arnold