Skip to content

Add match_lines_count in the Gitlab::Search::FoundBlob

What does this MR do and why?

This MR will add an attribute matched_lines_count in the Gitlab::Search::FoundBlob. The value of matched_lines_count is calculated by counting the match of the regex in the content of the whole file. The regex will match ::Elastic::Latest::GitClassProxy::HIGHLIGHT_START_TAG(Any content)(Line break) This value can be used in the frontend to display the total number of lines containing the searched keyword.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Start the local development environment
gdk start
  1. Ensure elasticsearch is running
  2. Turn on the Advanced search from the /admin
  3. Put a breakpoint(eg: binding.pry) in the show action of app/controllers/search_controller.rb after setting of @global_search_duration_s
  4. Verify the value of @search_objects contains the attribute matched_lines_count with values.
  5. You can verify the value by opening the full file as raw and manually counting the number of lines the searched keyword appears. This value must be almost equal if not equal to the matched_lines_count

MR acceptance checklist

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

Related to #385452 (closed)

Edited by Ravi Kumar

Merge request reports