Welcome to mirror list, hosted at ThFree Co, Russian Federation.

search_controller.rb « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8df84e9884a2fc38fc551afcddc89da0893fa4c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class SearchController < ApplicationController
  include SearchHelper

  def show
    @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?

    if @project
      return access_denied! unless can?(current_user, :download_code, @project)

      @search_results = Search::ProjectService.new(@project, current_user, params).execute
    else
      @search_results = Search::GlobalService.new(current_user, params).execute
    end
  end

  def autocomplete
    term = params[:term]
    @project = Project.find(params[:project_id]) if params[:project_id].present?
    @ref = params[:project_ref] if params[:project_ref].present?

    render json: search_autocomplete_opts(term).to_json
  end
end