Skip to content

Capture suggested reviewers accepted

Tan Le requested to merge capture-suggested-reviewers-accepted into master

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 the reviewer_ids params
  • backend Invoke the CaptureSuggestedReviewersAcceptedServive to record the reviewer_ids on the existing merge_request_predictions table.
  • database Add a new column accepted_reviewers to merge_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

Screen_Shot_2022-11-16_at_22.15.38

How to set up and validate locally

  1. Ensure a SaaS (Gitlab.com) environment
    1. One way of doing this is to add a env.runit file to the root GDK folder with the following snippet
      export GITLAB_SIMULATE_SAAS=1
  2. Set ultimate license on a group http://gdk.test:3000/admin/groups
  3. Create a project in the ultimate group or use an existing one, e.g. http://gdk.test:3000/gitlab-org/gitlab-test
  4. Set the feature flag on rails console bundle exec rails c
    project = Project.find(2)
    Feature.enable(:suggested_reviewers_control, project)
  5. Enable suggested_reviewers_enabled project settings
    project.project_setting.update!(suggested_reviewers_enabled: true)
  6. Create a merge request on the project
  7. Use some existing project members
    suggested_reviewers = ["lea_mclaughlin", "ken"]
  8. Add some suggestions to an existing open MR
    mr = MergeRequest.find(7)
    mr.build_predictions
    mr.predictions.update!(suggested_reviewers: { reviewers: suggested_reviewers })
  9. Navigate to the MR view page and confirm that we can see the suggested reviewers
  10. Click on one of the suggested reviewers, e.g "ken"
  11. 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.

Relates to https://gitlab.com/gitlab-org/modelops/applied-ml/review-recommender/recommender-bot-service/-/issues/65

Edited by Tan Le

Merge request reports