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
- Start the local development environment
gdk start
- Ensure elasticsearch is running
- Turn on the Advanced search from the
/admin
- Put a breakpoint(eg: binding.pry) in the
show
action ofapp/controllers/search_controller.rb
after setting of@global_search_duration_s
- Verify the value of
@search_objects
contains the attributematched_lines_count
with values. - 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #385452 (closed)
Edited by Ravi Kumar