Skip to content

Always pass current_user to project search results

Terri Chu requested to merge tc-fix-blob-aggs-missing-from-project-search into master

What does this MR do and why?

Related #342648 (closed)

Discovered while rolling out the Feature Flag: search_blobs_language_aggregation via #342621 (closed)

The feature flag only works on Global and Group level code search, but not Project level code search.

I traced the bug down to not having the current_user passed into the objects used by project_search_results.rb

This MR:

  • passes current_user and other base_options to the ProjectSearchResults object
  • only check if blob aggregations should be handled when creating the Elasticsearch query, NOT reading Elasticsearch response
  • refactors existing specs, including one that was passing but written poorly so it didn't catch the 🐛

Screenshots or screen recordings

N/A

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Have Elasticsearch setup for gdk
  2. Enable Advanced Search and have data indexed
  3. Enable the feature flag in the rails console
    Feature.enable(:search_blobs_language_aggregation)
  4. perform a code search for global, group, and project level
  5. for each, verify using the performance bar that the Elasticsearch query contains the aggs section
drawing

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Terri Chu

Merge request reports