Adding snippet search capability
Created by: bushong1
In reference to this merge request:
http://feedback.gitlab.com/forums/176466-general/suggestions/5529795-search-though-snippets
What does this MR do?
Adds the capability to search snippets. This can be accessed whenever viewing a snippet related page, such as personal snippets, snippet discovery, and search snippets. There is a tab for searching just filenames and titles, and there is a tab for searching just the code of the snippet. It searches all public snippets, as well as the private snippets of the user.
Are there points in the code the reviewer needs to double check?
The biggest change is the creation of snippet_service.rb
in app/services/search/snippet_service.rb
. One thing I was unsure of was if there is any specific limit on how many snippet results should be returned in total from the query. I didn't want to leave it unlimited, as a user could search for a single character and potentially slow down the system. I put the limit at an arbitrary 500, paginating at 20 for the user, but someone may want to make a judgement call.
Why was this MR needed?
This is something my users have been asking for, and it should add a great amount of collaborative capability and global discovery to the snippets feature. In addition, there is a merge request already created with 9 points.
What are the relevant issue numbers / Feature requests?
http://feedback.gitlab.com/forums/176466-general/suggestions/5529795-search-though-snippets
Screenshots (If appropiate)
Image 1: Searching title/filename with no results.
Image 2: Searching code with results.
Image 3: Searching title/filename with paginated results, first page. (the black bar towards the bottom is just ubuntu butting in while i maximize for a screenshot) Image 4: Searching title/filename with paginated results, second page. Image 5: "Search Snippets" in search bar available on this page. Image 6: Searching in code will display text 3 lines before and 3 lines after any matches. It will collapse overlapping matches into one block.