Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
70a65182
Commit
70a65182
authored
May 11, 2020
by
Vitali Tatarintev
Committed by
Peter Leitzen
May 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose Alert#issue_iid in GraphQL endpoint
Exposes the issue IID attached to `AlertManagement::Alert`
parent
0cebbe86
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
1 deletion
+37
-1
app/graphql/types/alert_management/alert_type.rb
app/graphql/types/alert_management/alert_type.rb
+5
-0
app/models/alert_management/alert.rb
app/models/alert_management/alert.rb
+2
-0
changelogs/unreleased/expose-issue-iid-in-alert-management-alert-graphql.yml
...ed/expose-issue-iid-in-alert-management-alert-graphql.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+5
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+14
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
spec/graphql/types/alert_management/alert_type_spec.rb
spec/graphql/types/alert_management/alert_type_spec.rb
+1
-0
spec/requests/api/graphql/project/alert_management/alerts_spec.rb
...uests/api/graphql/project/alert_management/alerts_spec.rb
+4
-1
No files found.
app/graphql/types/alert_management/alert_type.rb
View file @
70a65182
...
...
@@ -13,6 +13,11 @@ module Types
null:
false
,
description:
'Internal ID of the alert'
field
:issue_iid
,
GraphQL
::
ID_TYPE
,
null:
true
,
description:
'Internal ID of the GitLab issue attached to the alert'
field
:title
,
GraphQL
::
STRING_TYPE
,
null:
true
,
...
...
app/models/alert_management/alert.rb
View file @
70a65182
...
...
@@ -92,6 +92,8 @@ module AlertManagement
end
end
delegate
:iid
,
to: :issue
,
prefix:
true
,
allow_nil:
true
scope
:for_iid
,
->
(
iid
)
{
where
(
iid:
iid
)
}
scope
:for_fingerprint
,
->
(
project
,
fingerprint
)
{
where
(
project:
project
,
fingerprint:
fingerprint
)
}
...
...
changelogs/unreleased/expose-issue-iid-in-alert-management-alert-graphql.yml
0 → 100644
View file @
70a65182
---
title
:
Exposes issue IID in Alert Management Alert's GraphQL endpoint
merge_request
:
31313
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
70a65182
...
...
@@ -177,6 +177,11 @@ type AlertManagementAlert {
"""
iid
:
ID
!
"""
Internal
ID
of
the
GitLab
issue
attached
to
the
alert
"""
issueIid
:
ID
"""
Monitoring
tool
the
alert
came
from
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
70a65182
...
...
@@ -504,6 +504,20 @@
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"issueIid"
,
"description"
:
"Internal ID of the GitLab issue attached to the alert"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"ID"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"monitoringTool"
,
"description"
:
"Monitoring tool the alert came from"
,
...
...
doc/api/graphql/reference/index.md
View file @
70a65182
...
...
@@ -59,6 +59,7 @@ Describes an alert from the project's Alert Management
|
`eventCount`
| Int | Number of events of this alert |
|
`hosts`
| String! => Array | List of hosts the alert came from |
|
`iid`
| ID! | Internal ID of the alert |
|
`issueIid`
| ID | Internal ID of the GitLab issue attached to the alert |
|
`monitoringTool`
| String | Monitoring tool the alert came from |
|
`service`
| String | Service the alert came from |
|
`severity`
| AlertManagementSeverity | Severity of the alert |
...
...
spec/graphql/types/alert_management/alert_type_spec.rb
View file @
70a65182
...
...
@@ -10,6 +10,7 @@ describe GitlabSchema.types['AlertManagementAlert'] do
it
'exposes the expected fields'
do
expected_fields
=
%i[
iid
issue_iid
title
description
severity
...
...
spec/requests/api/graphql/project/alert_management/alerts_spec.rb
View file @
70a65182
...
...
@@ -7,7 +7,7 @@ describe 'getting Alert Management Alerts' do
let_it_be
(
:payload
)
{
{
'custom'
=>
{
'alert'
=>
'payload'
}
}
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:alert_1
)
{
create
(
:alert_management_alert
,
:all_fields
,
:resolved
,
project:
project
,
severity: :low
)
}
let_it_be
(
:alert_1
)
{
create
(
:alert_management_alert
,
:all_fields
,
:resolved
,
project:
project
,
issue:
nil
,
severity: :low
)
}
let_it_be
(
:alert_2
)
{
create
(
:alert_management_alert
,
:all_fields
,
project:
project
,
severity: :critical
,
payload:
payload
)
}
let_it_be
(
:other_project_alert
)
{
create
(
:alert_management_alert
,
:all_fields
)
}
...
...
@@ -58,6 +58,7 @@ describe 'getting Alert Management Alerts' do
it
'returns the correct properties of the alerts'
do
expect
(
first_alert
).
to
include
(
'iid'
=>
alert_2
.
iid
.
to_s
,
'issueIid'
=>
alert_2
.
issue_iid
.
to_s
,
'title'
=>
alert_2
.
title
,
'description'
=>
alert_2
.
description
,
'severity'
=>
alert_2
.
severity
.
upcase
,
...
...
@@ -74,6 +75,8 @@ describe 'getting Alert Management Alerts' do
)
expect
(
second_alert
).
to
include
(
'iid'
=>
alert_1
.
iid
.
to_s
,
'issueIid'
=>
nil
,
'status'
=>
'RESOLVED'
,
'endedAt'
=>
alert_1
.
ended_at
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment