Merge branch '323631-remove-participant-on-removal' into 'master'
Remove user from rotation if removed from project/group ## What does this MR do? <!-- Describe in detail what your merge request does and why. Are there any risks involved with the proposed change? What additional test coverage is introduced to offset the risk? Please keep this description up-to-date with any discussion that takes place so that reviewers can understand your intent. This is especially important if they didn't participate in the discussion. --> This adds a service to remove a user from an On-call Rotation. We ensure that the rotation is up to date by running the job top persist current shifts. Then, we update the `is_removed` boolean on the Participant model associated to the user/rotation. Deletion from rotations are scoped to the member being removed: - If a member is a project member, only that project's rotations are affected - If a member is a group member, all of the projects within that group are affected **Why don't we use the existing [`EditRotationService`](https://gitlab.com/gitlab-org/gitlab/-/blob/9c35c043a9ce9d70bd30ec6dc0d30991bf15ab29/ee/app/services/incident_management/oncall_rotations/edit_service.rb) service?** The `EditRotationService` requires you to provide all `participant` params for all remaining participants, and in a format which requires the `user`, `color_palette`, `color_weight` etc. Rather than modify the `EditRotationService` to make this easier, I chose to make a specific service for this use case. SQL queries for finder: Single Project: Explain: https://explain.depesz.com/s/QToy SQL: ```sql User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 /*application:console,line:/ee/app/finders/incident_management/member_oncall_rotations_finder.rb:11:in `initialize'*/ Project Load (0.5ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = 4302 LIMIT 1 /*application:console,line:/ee/app/finders/incident_management/member_oncall_rotations_finder.rb:15:in `execute'*/ IncidentManagement::OncallRotation Load (4.5ms) SELECT "incident_management_oncall_rotations".* FROM "incident_management_oncall_rotations" INNER JOIN "incident_management_oncall_participants" ON "incident_management_oncall_rotations"."id" = "incident_management_oncall_participants"."oncall_rotation_id" INNER JOIN "incident_management_oncall_schedules" ON "incident_management_oncall_schedules"."id" = "incident_management_oncall_rotations"."oncall_schedule_id" WHERE "incident_management_oncall_participants"."user_id" = 1 AND "incident_management_oncall_schedules"."project_id" = 4302 ``` Group member, multiple projects: Explain: https://explain.depesz.com/s/3sxa SQL: ```sql User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 Namespace Load (0.5ms) SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = 4374 LIMIT 1 IncidentManagement::OncallRotation Load (1.1ms) SELECT "incident_management_oncall_rotations".* FROM "incident_management_oncall_rotations" INNER JOIN "incident_management_oncall_participants" ON "incident_management_oncall_rotations"."id" = "incident_management_oncall_participants"."oncall_rotation_id" INNER JOIN "incident_management_oncall_schedules" ON "incident_management_oncall_schedules"."id" = "incident_management_oncall_rotations"."oncall_schedule_id" WHERE "incident_management_oncall_participants"."user_id" = 1 AND "incident_management_oncall_schedules"."project_id" IN (SELECT "projects"."id" FROM "projects" WHERE "projects"."namespace_id" = 4374) ``` ## 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 -📋 [Does this MR need a changelog?](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry) - [x] I have included a changelog entry. - [ ] I have not included a changelog entry because _____. - [ ] [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) - [ ] [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) - [x] [Separation of EE specific content](https://docs.gitlab.com/ee/development/ee_features.html#separation-of-ee-code) ### Availability and Testing <!-- What risks does this change pose? How might it affect the quality/performance of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing? See the test engineering process for further guidelines: https://about.gitlab.com/handbook/engineering/quality/test-engineering/ --> <!-- If cross-browser testing is not required, please remove the relevant item, or mark it as not needed: [-] --> - [ ] [Review and add/update tests for this feature/bug](https://docs.gitlab.com/ee/development/testing_guide/index.html). Consider [all test levels](https://docs.gitlab.com/ee/development/testing_guide/testing_levels.html). See the [Test Planning Process](https://about.gitlab.com/handbook/engineering/quality/test-engineering). - [ ] [Tested in all supported browsers](https://docs.gitlab.com/ee/install/requirements.html#supported-web-browsers) - [ ] Informed Infrastructure department of a default or new setting change, if applicable per [definition of done](https://docs.gitlab.com/ee/development/contributing/merge_request_workflow.html#definition-of-done) ### Security If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in [the security review guidelines](https://about.gitlab.com/handbook/engineering/security/#when-to-request-a-security-review): - [ ] Label as ~security and @ mention `@gitlab-com/gl-security/appsec` - [ ] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods - [ ] Security reports checked/validated by a reviewer from the AppSec team Related to #323631 See merge request gitlab-org/gitlab!59427
Showing
Please register or sign in to comment