Capture suggested reviewers accepted
What does this MR do and why?
This MR allows us to keep track of suggested reviewers being selected by end-users. Newly accepted suggested reviewers will be compared against the suggested list and the existing accepted list before being added to the accepted_reviewers
field in the merge_request_predictions
table.
The front-end facing feature is behind a feature flag suggested_reviewers_control
Implementation
-
frontend Capture
suggested_reviewer_ids
from VueJS component. This only emits new reviewer assignments. -
backend Filter the list of
suggested_reviewer_ids
based on thereviewer_ids
params -
backend Invoke the
CaptureSuggestedReviewersAcceptedServive
to record thereviewer_ids
on the existingmerge_request_predictions
table. -
database Add a new column
accepted_reviewers
tomerge_request_predictions
table
Migration
❯ bin/rails db:migrate:up VERSION=20221107013943
main: == 20221107013943 AddAcceptedReviewersToMergeRequestPredictions: migrating ====
main: -- add_column(:merge_request_predictions, :accepted_reviewers, :jsonb, {:null=>false, :default=>{}})
main: -> 0.0022s
main: == 20221107013943 AddAcceptedReviewersToMergeRequestPredictions: migrated (0.0027s)
❯ bin/rails db:migrate:down VERSION=20221107013943
main: == 20221107013943 AddAcceptedReviewersToMergeRequestPredictions: reverting ====
main: -- remove_column(:merge_request_predictions, :accepted_reviewers, :jsonb, {:null=>false, :default=>{}})
main: -> 0.0058s
main: == 20221107013943 AddAcceptedReviewersToMergeRequestPredictions: reverted (0.0108s)
Screenshots or screen recordings
How to set up and validate locally
- Ensure a SaaS (Gitlab.com) environment
- One way of doing this is to add a
env.runit
file to the root GDK folder with the following snippetexport GITLAB_SIMULATE_SAAS=1
- One way of doing this is to add a
- Set ultimate license on a group
http://gdk.test:3000/admin/groups
- Create a project in the ultimate group or use an existing one, e.g.
http://gdk.test:3000/gitlab-org/gitlab-test
- Set the feature flag on rails console
bundle exec rails c
project = Project.find(2) Feature.enable(:suggested_reviewers_control, project)
- Enable
suggested_reviewers_enabled
project settingsproject.project_setting.update!(suggested_reviewers_enabled: true)
- Create a merge request on the project
- Use some existing project members
suggested_reviewers = ["lea_mclaughlin", "ken"]
- Add some suggestions to an existing open MR
mr = MergeRequest.find(7) mr.build_predictions mr.predictions.update!(suggested_reviewers: { reviewers: suggested_reviewers })
- Navigate to the MR view page and confirm that we can see the suggested reviewers
- Click on one of the suggested reviewers, e.g "ken"
- Confirm that the reviewers are recorded in the database
mr.predictions.accepted_reviewers => {"reviewers"=>["ken"]}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Tan Le