diff options
author | Izaak Alpert <ialpert@blackberry.com> | 2013-10-24 19:16:14 +0400 |
---|---|---|
committer | Izaak Alpert <ialpert@blackberry.com> | 2013-10-24 19:23:26 +0400 |
commit | 0f87ae3be5d7d1bc0a3728f43ae0465005b68b92 (patch) | |
tree | 3b782b6196317329d3b3a52f568306e24769f4d5 /app/contexts/search_context.rb | |
parent | cddec75dc1e309483aa80ea4533ff972507686ef (diff) |
Allow searching by namespace name, include public projects
GITLAB-1457 (GITLAB-836)
Change-Id: If8e2474bc6908accca51f395f58937687f101b58
Diffstat (limited to 'app/contexts/search_context.rb')
-rw-r--r-- | app/contexts/search_context.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/contexts/search_context.rb b/app/contexts/search_context.rb index 48def0784fd..221f07fd3af 100644 --- a/app/contexts/search_context.rb +++ b/app/contexts/search_context.rb @@ -9,11 +9,14 @@ class SearchContext query = params[:search] return result unless query.present? - - projects = Project.where(id: project_ids) - result[:projects] = projects.search(query).limit(20) + result[:projects] = Project.where("projects.id in (?) OR projects.public = true", project_ids).search(query).limit(20) # Search inside single project + single_project_search(Project.where(id: project_ids), query) + result + end + + def single_project_search(projects, query) project = projects.first if projects.length == 1 if params[:search_code].present? @@ -23,7 +26,6 @@ class SearchContext result[:issues] = Issue.where(project_id: project_ids).search(query).order('updated_at DESC').limit(20) result[:wiki_pages] = [] end - result end def result |