Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Castro <javier.alejandro.castro@gmail.com>2013-04-14 21:07:11 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-05-09 12:47:08 +0400
commit7f57fe5034f6fdfbdd4e29745b50e7bfa1576bf5 (patch)
tree29586c1f9dd79b73b88e1797e26b432f9d18fd40 /app/contexts/search_context.rb
parent4353babe61a57be128bd967731e7c536c9a55ba3 (diff)
Implemented code search feature
Diffstat (limited to 'app/contexts/search_context.rb')
-rw-r--r--app/contexts/search_context.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/contexts/search_context.rb b/app/contexts/search_context.rb
index de6542e82f4..854c369ea4a 100644
--- a/app/contexts/search_context.rb
+++ b/app/contexts/search_context.rb
@@ -10,7 +10,11 @@ class SearchContext
return result unless query.present?
- result[:projects] = Project.where(id: project_ids).search(query).limit(10)
+ projects = Project.where(id: project_ids)
+ result[:projects] = projects.search(query).limit(10)
+ if projects.length == 1
+ result[:snippets] = projects.first.files(query, params[:branch_ref])
+ end
result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10)
result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10)
result[:wiki_pages] = []
@@ -22,7 +26,8 @@ class SearchContext
projects: [],
merge_requests: [],
issues: [],
- wiki_pages: []
+ wiki_pages: [],
+ snippets: []
}
end
end