Only trigger actual search if a search string is present

This commit is contained in:
Hannes Rosenögger 2015-01-21 22:06:21 +01:00
parent 6c1074e302
commit 9487c37037

View file

@ -2,12 +2,14 @@ class SearchController < ApplicationController
include SearchHelper include SearchHelper
def show def show
return if params[:search].nil? || params[:search].blank?
@project = Project.find_by(id: params[:project_id]) if params[:project_id].present? @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? @group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
@scope = params[:scope] @scope = params[:scope]
@show_snippets = params[:snippets].eql? 'true' @show_snippets = params[:snippets].eql? 'true'
@search_results = if @project @search_results =
if @project
return access_denied! unless can?(current_user, :download_code, @project) return access_denied! unless can?(current_user, :download_code, @project)
unless %w(blobs notes issues merge_requests wiki_blobs). unless %w(blobs notes issues merge_requests wiki_blobs).
@ -26,10 +28,8 @@ class SearchController < ApplicationController
unless %w(projects issues merge_requests).include?(@scope) unless %w(projects issues merge_requests).include?(@scope)
@scope = 'projects' @scope = 'projects'
end end
Search::GlobalService.new(current_user, params).execute Search::GlobalService.new(current_user, params).execute
end end
@objects = @search_results.objects(@scope, params[:page]) @objects = @search_results.objects(@scope, params[:page])
end end