Restrict on-call to certain times during rotations
What does this MR do?
This adds the ability to restrict an oncall rotation (and it's shift) to a time active period (i.e between the hours of 8am and 5pm
).
To allow this we have:
- Added two more columns to
incident_management_oncall_rotations
;active_period_start
,active_period_end
. - Added two fields to the GraphQL mutation to create Oncall Rotations
DB Migrations:
Up:
== 20210201034649 AddActivePeriodsToOnCallRotations: migrating ================
-- add_column(:incident_management_oncall_rotations, :active_period_start, :text, {:null=>true})
-> 0.0032s
-- add_column(:incident_management_oncall_rotations, :active_period_end, :text, {:null=>true})
-> 0.0004s
== 20210201034649 AddActivePeriodsToOnCallRotations: migrated (0.0037s) =======
== 20210205051437 AddTextLimitToRotationActivePeriodsColumns: migrating =======
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_oncall_rotations\nADD CONSTRAINT check_30b841c47f\nCHECK ( char_length(active_period_start) <= 5 )\nNOT VALID;\n")
-> 0.0038s
-- current_schema()
-> 0.0002s
-- execute("SET statement_timeout TO 0")
-> 0.0001s
-- execute("ALTER TABLE incident_management_oncall_rotations VALIDATE CONSTRAINT check_30b841c47f;")
-> 0.0014s
-- execute("RESET ALL")
-> 0.0001s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_oncall_rotations\nADD CONSTRAINT check_10f7ba666c\nCHECK ( char_length(active_period_end) <= 5 )\nNOT VALID;\n")
-> 0.0006s
-- current_schema()
-> 0.0001s
-- execute("ALTER TABLE incident_management_oncall_rotations VALIDATE CONSTRAINT check_10f7ba666c;")
-> 0.0004s
== 20210205051437 AddTextLimitToRotationActivePeriodsColumns: migrated (0.0155s)
Down:
== 20210201034649 AddActivePeriodsToOnCallRotations: reverting ================
-- remove_column(:incident_management_oncall_rotations, :active_period_end, :text, {:null=>true})
-> 0.0097s
-- remove_column(:incident_management_oncall_rotations, :active_period_start, :text, {:null=>true})
-> 0.0003s
== 20210201034649 AddActivePeriodsToOnCallRotations: reverted (0.0129s) =======
== 20210205051437 AddTextLimitToRotationActivePeriodsColumns: reverting =======
-- execute("ALTER TABLE incident_management_oncall_rotations\nDROP CONSTRAINT IF EXISTS check_30b841c47f\n")
-> 0.0004s
-- execute("ALTER TABLE incident_management_oncall_rotations\nDROP CONSTRAINT IF EXISTS check_10f7ba666c\n")
-> 0.0002s
== 20210205051437 AddTextLimitToRotationActivePeriodsColumns: reverted (0.0075s)
GraphQL Query
Mutation
mutation newRotation($input: OncallRotationCreateInput!) {
oncallRotationCreate(input: $input) {
oncallRotation {
id
name
startsAt
length
lengthUnit
activePeriodStart
activePeriodEnd
participants {
nodes {
user {
username
}
colorWeight
colorPalette
}
}
}
errors
}
}
Input
{
"input": {
"projectPath": "root/autodevops-deploy-test",
"scheduleIid": "1",
"name": "test rotation 6",
"startsAt": {
"date": "2021-02-01",
"time": "08:00"
},
"rotationLength": {
"length": 1,
"unit": "DAYS"
},
"participants": [
{
"username": "root",
"colorWeight": "WEIGHT_500",
"colorPalette": "GREEN"
}
],
"activePeriod": {
"from": "08:00",
"to": "17:00"
}
}
}
Output
{
"data": {
"oncallRotationCreate": {
"oncallRotation": {
"id": "gid://gitlab/IncidentManagement::OncallRotation/20",
"name": "test rotation 3",
"startsAt": "2021-01-31T19:00:00Z",
"length": 1,
"lengthUnit": "DAYS",
"activePeriodStart": "08:00",
"activePeriodEnd": "17:00",
"participants": {
"nodes": [
{
"user": {
"username": "root"
},
"colorWeight": "500",
"colorPalette": "green"
}
]
}
},
"errors": []
}
}
}
</details>
## Screenshots (strongly suggested)
<!--
Please include any relevant screenshots that will assist reviewers and
future readers. If you need help visually verifying the change, please
leave a comment and ping a GitLab reviewer, maintainer, or MR coach.
-->
## Does this MR meet the acceptance criteria?
### Conformity
- [x] [Changelog entry](https://docs.gitlab.com/ee/development/changelog.html)
- [x] [Documentation](https://docs.gitlab.com/ee/development/documentation/workflow.html) ([if required](https://about.gitlab.com/handbook/engineering/ux/technical-writing/workflow/#when-documentation-is-required))
- [x] [Code review guidelines](https://docs.gitlab.com/ee/development/code_review.html)
- [x] [Merge request performance guidelines](https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html)
- [x] [Style guides](https://gitlab.com/gitlab-org/gitlab-ee/blob/master/doc/development/contributing/style_guides.md)
- [x] [Database guides](https://docs.gitlab.com/ee/development/database_review.html)
- [-] [Separation of EE specific content](https://docs.gitlab.com/ee/development/ee_features.html#separation-of-ee-code)
Related to #262859
Edited by Peter Leitzen