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
3627c31d
Commit
3627c31d
authored
May 06, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up code
- Reword changelog
parent
d4ba84a2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
app/graphql/mutations/alert_management/update_alert_status.rb
...graphql/mutations/alert_management/update_alert_status.rb
+3
-3
app/services/alert_management/update_alert_status_service.rb
app/services/alert_management/update_alert_status_service.rb
+13
-6
changelogs/unreleased/214542-graphql-status-mutation.yml
changelogs/unreleased/214542-graphql-status-mutation.yml
+1
-1
No files found.
app/graphql/mutations/alert_management/update_alert_status.rb
View file @
3627c31d
...
@@ -13,20 +13,20 @@ module Mutations
...
@@ -13,20 +13,20 @@ module Mutations
alert
=
authorized_find!
(
project_path:
args
[
:project_path
],
iid:
args
[
:iid
])
alert
=
authorized_find!
(
project_path:
args
[
:project_path
],
iid:
args
[
:iid
])
result
=
update_status
(
alert
,
args
[
:status
])
result
=
update_status
(
alert
,
args
[
:status
])
prepare_response
(
result
)
prepare_response
(
result
)
end
end
private
private
def
update_status
(
alert
,
status
)
def
update_status
(
alert
,
status
)
service
=
::
AlertManagement
::
UpdateAlertStatusService
.
new
(
alert
,
status
)
::
AlertManagement
::
UpdateAlertStatusService
.
new
(
alert
,
status
).
execute
service
.
execute
end
end
def
prepare_response
(
result
)
def
prepare_response
(
result
)
{
{
alert:
result
.
payload
[
:alert
],
alert:
result
.
payload
[
:alert
],
errors:
result
.
error?
?
[
result
.
message
]
.
compact
:
[]
errors:
result
.
error?
?
[
result
.
message
]
:
[]
}
}
end
end
end
end
...
...
app/services/alert_management/update_alert_status_service.rb
View file @
3627c31d
...
@@ -8,20 +8,27 @@ module AlertManagement
...
@@ -8,20 +8,27 @@ module AlertManagement
end
end
def
execute
def
execute
return
error
_response
(
'Invalid status'
)
unless
AlertManagement
::
Alert
.
statuses
.
key?
(
status
.
to_s
)
return
error
(
'Invalid status'
)
unless
AlertManagement
::
Alert
.
statuses
.
key?
(
status
.
to_s
)
alert
.
status
=
status
alert
.
status
=
status
return
ServiceResponse
.
success
(
payload:
{
alert:
alert
})
if
alert
.
save
error_response
(
alert
.
errors
.
full_messages
.
to_sentence
)
if
alert
.
save
success
else
error
(
alert
.
errors
.
full_messages
.
to_sentence
)
end
end
end
private
private
def
error_response
(
message
)
attr_reader
:alert
,
:status
ServiceResponse
.
error
(
payload:
{
alert:
alert
},
message:
message
)
def
success
ServiceResponse
.
success
(
payload:
{
alert:
alert
})
end
end
attr_reader
:alert
,
:status
def
error
(
message
)
ServiceResponse
.
error
(
payload:
{
alert:
alert
},
message:
message
)
end
end
end
end
end
changelogs/unreleased/214542-graphql-status-mutation.yml
View file @
3627c31d
---
---
title
:
Add mutation for AlertManagementAlert status
title
:
Add mutation for AlertManagement
's
Alert status
merge_request
:
30576
merge_request
:
30576
author
:
author
:
type
:
added
type
:
added
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