Commit 1d5bb484 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'rest-severity' into 'master'

Added severity to issues REST API

See merge request gitlab-org/gitlab!82696
parents 0dc514c2 3693c7f1
...@@ -135,7 +135,7 @@ class Issue < ApplicationRecord ...@@ -135,7 +135,7 @@ class Issue < ApplicationRecord
scope :with_prometheus_alert_events, -> { joins(:issues_prometheus_alert_events) } scope :with_prometheus_alert_events, -> { joins(:issues_prometheus_alert_events) }
scope :with_self_managed_prometheus_alert_events, -> { joins(:issues_self_managed_prometheus_alert_events) } scope :with_self_managed_prometheus_alert_events, -> { joins(:issues_self_managed_prometheus_alert_events) }
scope :with_api_entity_associations, -> { scope :with_api_entity_associations, -> {
preload(:timelogs, :closed_by, :assignees, :author, :labels, preload(:timelogs, :closed_by, :assignees, :author, :labels, :issuable_severity,
milestone: { project: [:route, { namespace: :route }] }, milestone: { project: [:route, { namespace: :route }] },
project: [:route, { namespace: :route }]) project: [:route, { namespace: :route }])
} }
......
...@@ -165,6 +165,7 @@ Example response: ...@@ -165,6 +165,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links":{ "_links":{
"self":"http://gitlab.example.com/api/v4/projects/1/issues/76", "self":"http://gitlab.example.com/api/v4/projects/1/issues/76",
"notes":"http://gitlab.example.com/api/v4/projects/1/issues/76/notes", "notes":"http://gitlab.example.com/api/v4/projects/1/issues/76/notes",
...@@ -390,6 +391,7 @@ Example response: ...@@ -390,6 +391,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links":{ "_links":{
"self":"http://gitlab.example.com/api/v4/projects/4/issues/41", "self":"http://gitlab.example.com/api/v4/projects/4/issues/41",
"notes":"http://gitlab.example.com/api/v4/projects/4/issues/41/notes", "notes":"http://gitlab.example.com/api/v4/projects/4/issues/41/notes",
...@@ -598,6 +600,7 @@ Example response: ...@@ -598,6 +600,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links":{ "_links":{
"self":"http://gitlab.example.com/api/v4/projects/4/issues/41", "self":"http://gitlab.example.com/api/v4/projects/4/issues/41",
"notes":"http://gitlab.example.com/api/v4/projects/4/issues/41/notes", "notes":"http://gitlab.example.com/api/v4/projects/4/issues/41/notes",
...@@ -755,6 +758,7 @@ Example response: ...@@ -755,6 +758,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"task_completion_status": { "task_completion_status": {
"count": 0, "count": 0,
"completed_count": 0 "completed_count": 0
...@@ -917,6 +921,7 @@ Example response: ...@@ -917,6 +921,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links": { "_links": {
"self": "http://gitlab.example.com/api/v4/projects/1/issues/2", "self": "http://gitlab.example.com/api/v4/projects/1/issues/2",
"notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes", "notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes",
...@@ -1064,6 +1069,7 @@ Example response: ...@@ -1064,6 +1069,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links": { "_links": {
"self": "http://gitlab.example.com/api/v4/projects/1/issues/2", "self": "http://gitlab.example.com/api/v4/projects/1/issues/2",
"notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes", "notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes",
...@@ -1238,6 +1244,7 @@ Example response: ...@@ -1238,6 +1244,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links": { "_links": {
"self": "http://gitlab.example.com/api/v4/projects/1/issues/2", "self": "http://gitlab.example.com/api/v4/projects/1/issues/2",
"notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes", "notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes",
...@@ -1421,6 +1428,7 @@ Example response: ...@@ -1421,6 +1428,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links": { "_links": {
"self": "http://gitlab.example.com/api/v4/projects/1/issues/2", "self": "http://gitlab.example.com/api/v4/projects/1/issues/2",
"notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes", "notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes",
...@@ -1560,6 +1568,7 @@ Example response: ...@@ -1560,6 +1568,7 @@ Example response:
"confidential":false, "confidential":false,
"discussion_locked":null, "discussion_locked":null,
"issue_type":"issue", "issue_type":"issue",
"severity": "UNKNOWN",
"web_url":"https://gitlab.example.com/namespace1/project2/-/issues/1", "web_url":"https://gitlab.example.com/namespace1/project2/-/issues/1",
"time_stats":{ "time_stats":{
"time_estimate":0, "time_estimate":0,
...@@ -1669,6 +1678,7 @@ Example response: ...@@ -1669,6 +1678,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"_links": { "_links": {
"self": "http://gitlab.example.com/api/v4/projects/1/issues/2", "self": "http://gitlab.example.com/api/v4/projects/1/issues/2",
"notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes", "notes": "http://gitlab.example.com/api/v4/projects/1/issues/2/notes",
...@@ -1797,6 +1807,7 @@ Example response: ...@@ -1797,6 +1807,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"task_completion_status":{ "task_completion_status":{
"count":0, "count":0,
"completed_count":0 "completed_count":0
...@@ -1906,6 +1917,7 @@ Example response: ...@@ -1906,6 +1917,7 @@ Example response:
"confidential": false, "confidential": false,
"discussion_locked": false, "discussion_locked": false,
"issue_type": "issue", "issue_type": "issue",
"severity": "UNKNOWN",
"task_completion_status":{ "task_completion_status":{
"count":0, "count":0,
"completed_count":0 "completed_count":0
......
...@@ -35,6 +35,10 @@ module API ...@@ -35,6 +35,10 @@ module API
issue issue
end end
expose :severity,
format_with: :upcase,
documentation: { type: "String", desc: "One of #{::IssuableSeverity.severities.keys.map(&:upcase)}" }
# Calculating the value of subscribed field triggers Markdown # Calculating the value of subscribed field triggers Markdown
# processing. We can't do that for multiple issues / merge # processing. We can't do that for multiple issues / merge
# requests in a single API request. # requests in a single API request.
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
"due_date": { "type": ["string", "null"] }, "due_date": { "type": ["string", "null"] },
"confidential": { "type": "boolean" }, "confidential": { "type": "boolean" },
"web_url": { "type": "uri" }, "web_url": { "type": "uri" },
"severity": { "type": "string", "enum": ["UNKNOWN", "LOW", "MEDIUM", "HIGH", "CRITICAL"] },
"time_stats": { "time_stats": {
"time_estimate": { "type": "integer" }, "time_estimate": { "type": "integer" },
"total_time_spent": { "type": "integer" }, "total_time_spent": { "type": "integer" },
......
...@@ -554,6 +554,27 @@ RSpec.describe API::Issues do ...@@ -554,6 +554,27 @@ RSpec.describe API::Issues do
end end
end end
context 'with incident issues' do
let_it_be(:incident) { create(:incident, project: project) }
it 'avoids N+1 queries' do
get api('/issues', user) # warm up
control = ActiveRecord::QueryRecorder.new do
get api('/issues', user)
end
create(:incident, project: project)
create(:incident, project: project)
expect do
get api('/issues', user)
end.not_to exceed_query_limit(control)
# 2 pre-existed issues + 3 incidents
expect(json_response.count).to eq(5)
end
end
context 'filter by labels or label_name param' do context 'filter by labels or label_name param' do
context 'N+1' do context 'N+1' do
let(:label_b) { create(:label, title: 'foo', project: project) } let(:label_b) { create(:label, title: 'foo', project: project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment