diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-04-01 00:27:34 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-04-01 00:27:34 +0100 |
commit | 8d3ed6e49e1577e4198b7d5e60fd2e70cb3a446d (patch) | |
tree | 3d77ec54a8e97a75aee650a2ef4e464065af9c5d /app/controllers/search_controller.rb | |
parent | d0260cb7f20ba23672d773e5fc011f9c2cf81aaa (diff) | |
parent | b54acba8b732688c59fe2f38510c469dc86ee499 (diff) | |
download | gitlab-ce-30264-fix-vue-pagination.tar.gz |
Merge branch 'master' into 30264-fix-vue-pagination30264-fix-vue-pagination
* master:
Prevent users from disconnecting gitlab account from CAS
30276 Move issue, mr, todos next to profile dropdown in top nav
Refactor SearchController#show
Updating documentation to include a missing step in the update procedure
Fix link to Jira service documentation
Remove unnecessary ORDER BY clause from `forked_to_project_id` subquery
Fixed a gap underneath the scrolling inner page links
Add download attribute to download links
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r-- | app/controllers/search_controller.rb | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 612d69cf557..4a579601785 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -6,45 +6,19 @@ class SearchController < ApplicationController layout 'search' def show - if params[:project_id].present? - @project = Project.find_by(id: params[:project_id]) - @project = nil unless can?(current_user, :download_code, @project) - end + search_service = SearchService.new(current_user, params) - if params[:group_id].present? - @group = Group.find_by(id: params[:group_id]) - @group = nil unless can?(current_user, :read_group, @group) - end + @project = search_service.project + @group = search_service.group return if params[:search].blank? @search_term = params[:search] - @scope = params[:scope] - @show_snippets = params[:snippets].eql? 'true' - - @search_results = - if @project - unless %w(blobs notes issues merge_requests milestones wiki_blobs - commits).include?(@scope) - @scope = 'blobs' - end - - Search::ProjectService.new(@project, current_user, params).execute - elsif @show_snippets - unless %w(snippet_blobs snippet_titles).include?(@scope) - @scope = 'snippet_blobs' - end - - Search::SnippetService.new(current_user, params).execute - else - unless %w(projects issues merge_requests milestones).include?(@scope) - @scope = 'projects' - end - Search::GlobalService.new(current_user, params).execute - end - - @search_objects = @search_results.objects(@scope, params[:page]) + @scope = search_service.scope + @show_snippets = search_service.show_snippets? + @search_results = search_service.search_results + @search_objects = search_service.search_objects check_single_commit_result end |