diff options
author | Hannes Rosenögger <123haynes@gmail.com> | 2015-01-21 22:06:21 +0100 |
---|---|---|
committer | Hannes Rosenögger <123haynes@gmail.com> | 2015-03-19 10:50:34 +0100 |
commit | 9487c3703757ba013923125c4fe7774b9cea6f9b (patch) | |
tree | d17c42dd0d190f0402843d044540d014d0c77dd3 /app | |
parent | 6c1074e302fd77e87c454cede145dd92f15d0c55 (diff) | |
download | gitlab-ce-9487c3703757ba013923125c4fe7774b9cea6f9b.tar.gz |
Only trigger actual search if a search string is present
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/search_controller.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 55926a1ed22..a3284c82d3f 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -2,34 +2,34 @@ class SearchController < ApplicationController include SearchHelper def show + return if params[:search].nil? || params[:search].blank? @project = Project.find_by(id: params[:project_id]) if params[:project_id].present? @group = Group.find_by(id: params[:group_id]) if params[:group_id].present? @scope = params[:scope] @show_snippets = params[:snippets].eql? 'true' - @search_results = if @project - return access_denied! unless can?(current_user, :download_code, @project) - - unless %w(blobs notes issues merge_requests wiki_blobs). - 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).include?(@scope) - @scope = 'projects' - end - - Search::GlobalService.new(current_user, params).execute - end - + @search_results = + if @project + return access_denied! unless can?(current_user, :download_code, @project) + + unless %w(blobs notes issues merge_requests wiki_blobs). + 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).include?(@scope) + @scope = 'projects' + end + Search::GlobalService.new(current_user, params).execute + end @objects = @search_results.objects(@scope, params[:page]) end |