BigW Consortium Gitlab

search_controller.rb 799 Bytes
Newer Older
1
class SearchController < ApplicationController
2 3
  include SearchHelper

4
  def show
skv committed
5 6
    @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?
7 8 9

    if @project
      return access_denied! unless can?(current_user, :download_code, @project)
10
      @search_results = Search::ProjectService.new(@project, current_user, params).execute
11
    else
12
      @search_results = Search::GlobalService.new(current_user, params).execute
13 14
    end
  end
15 16 17 18 19 20 21 22

  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
23
end