diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-31 21:57:51 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-31 21:57:51 +0400 |
commit | a27e4404dbb553b3916c9f3c3202f41fb85cdffb (patch) | |
tree | 5d3915fd4033ad08908b488c69f35248365e1c09 /app/contexts/search_context.rb | |
parent | 9ab4539a629e8ab31fc775c71662a7cf4f2384d5 (diff) | |
parent | 0f87ae3be5d7d1bc0a3728f43ae0465005b68b92 (diff) |
Merge pull request #5435 from karlhungus/feature_search_namespace_name_and_public
Allow searching by namespace name, include public projects
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 c07fdfe4c39..2f9438f6bb4 100644 --- a/app/contexts/search_context.rb +++ b/app/contexts/search_context.rb @@ -10,11 +10,14 @@ class SearchContext query = Shellwords.shellescape(query) if query.present? 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? @@ -24,7 +27,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 |