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
41fa8e2d
Commit
41fa8e2d
authored
Mar 11, 2021
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify rotation params handling
parent
f20bb455
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
40 deletions
+22
-40
ee/app/graphql/mutations/incident_management/oncall_rotation/base.rb
...hql/mutations/incident_management/oncall_rotation/base.rb
+20
-14
ee/app/graphql/mutations/incident_management/oncall_rotation/create.rb
...l/mutations/incident_management/oncall_rotation/create.rb
+1
-7
ee/app/graphql/mutations/incident_management/oncall_rotation/update.rb
...l/mutations/incident_management/oncall_rotation/update.rb
+1
-19
No files found.
ee/app/graphql/mutations/incident_management/oncall_rotation/base.rb
View file @
41fa8e2d
...
...
@@ -38,22 +38,28 @@ module Mutations
end
def
parsed_params
(
schedule
,
participants
,
args
)
rotation_length
=
args
.
dig
(
:rotation_length
,
:length
)
rotation_length_unit
=
args
.
dig
(
:rotation_length
,
:unit
)
starts_at
=
parse_datetime
(
schedule
,
args
[
:starts_at
])
ends_at
=
parse_datetime
(
schedule
,
args
[
:ends_at
])
if
args
[
:ends_at
]
params
=
args
.
slice
(
:name
)
active_period_start
,
active_period_end
=
active_period_times
(
args
)
params
[
:participants
]
=
find_participants
(
participants
)
params
[
:starts_at
]
=
parse_datetime
(
schedule
,
args
[
:starts_at
])
if
args
[
:starts_at
]
params
[
:ends_at
]
=
parse_datetime
(
schedule
,
args
[
:ends_at
])
if
args
[
:ends_at
]
{
length:
rotation_length
,
length_unit:
rotation_length_unit
,
starts_at:
starts_at
,
ends_at:
ends_at
,
participants:
find_participants
(
participants
),
if
args
[
:rotation_length
]
params
.
merge!
(
length:
args
.
dig
(
:rotation_length
,
:length
),
length_unit:
args
.
dig
(
:rotation_length
,
:unit
)
)
end
if
args
[
:active_period
].
present?
active_period_start
,
active_period_end
=
active_period_times
(
args
)
params
.
merge!
(
active_period_start:
active_period_start
,
active_period_end:
active_period_end
}
)
end
params
end
def
parse_datetime
(
schedule
,
timestamp
)
...
...
ee/app/graphql/mutations/incident_management/oncall_rotation/create.rb
View file @
41fa8e2d
...
...
@@ -57,7 +57,7 @@ module Mutations
schedule
,
project
,
current_user
,
create_service
_params
(
schedule
,
participants
,
args
)
parsed
_params
(
schedule
,
participants
,
args
)
).
execute
response
(
result
)
...
...
@@ -65,12 +65,6 @@ module Mutations
rescue
ActiveRecord
::
RecordInvalid
=>
e
raise
Gitlab
::
Graphql
::
Errors
::
ArgumentError
,
e
.
message
end
private
def
create_service_params
(
schedule
,
participants
,
args
)
args
.
slice
(
:name
).
merge
(
parsed_params
(
schedule
,
participants
,
args
))
end
end
end
end
...
...
ee/app/graphql/mutations/incident_management/oncall_rotation/update.rb
View file @
41fa8e2d
...
...
@@ -43,7 +43,7 @@ module Mutations
result
=
::
IncidentManagement
::
OncallRotations
::
EditService
.
new
(
rotation
,
current_user
,
edit_service
_params
(
rotation
.
schedule
,
args
[
:participants
],
args
)
parsed
_params
(
rotation
.
schedule
,
args
[
:participants
],
args
)
).
execute
response
(
result
)
...
...
@@ -51,24 +51,6 @@ module Mutations
private
def
edit_service_params
(
schedule
,
participants
,
args
)
parsed_service_params
=
parsed_params
(
schedule
,
participants
,
args
)
args_to_update
=
parsed_service_params
.
slice
(
*
args
.
keys
)
if
args
[
:rotation_length
]
args_to_update
[
:length
]
=
parsed_service_params
[
:length
]
args_to_update
[
:length_unit
]
=
parsed_service_params
[
:length_unit
]
end
if
args
[
:active_period
]
args_to_update
[
:active_period_start
]
=
parsed_service_params
[
:active_period_start
]
args_to_update
[
:active_period_end
]
=
parsed_service_params
[
:active_period_end
]
end
args
.
slice
(
:name
).
merge
(
args_to_update
)
end
def
find_object
(
id
:)
GitlabSchema
.
object_from_id
(
id
,
expected_type:
::
IncidentManagement
::
OncallRotation
)
end
...
...
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