Skip to content

Refactor project custom role filter

Terri Chu requested to merge tchu-fix-n+1-in-search-filter into master

What does this MR do and why?

This MR refactors how custom roles are checked when determining the project list allowed during searches

Before it was checking each project individually but that created an N+1. This MR grabs the list of abilities required for the feature and checks all projects at once.

Note: this is how the old code worked, see filter_ids_by_ability method in Elastic::Latest::GitClassProxy

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

N/A

How to set up and validate locally

I ended up writing tests to validate the N+1 was fixed, the tests fail on master

to validate this manually:

  1. setup elasticsearch for gdk
  2. create a group and 2 projects
  3. create a custom role with guest access + read_code ability
  4. grant a user access to a group or a project with that role
  5. login as that user
  6. enable feature flag search_query_authorization_refactor
  7. perform a group search for code
  8. verify search works as expected
Edited by Terri Chu

Merge request reports

Loading