Class: Search::GlobalService

Inherits:
Object
  • Object
show all
Defined in:
app/services/search/global_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, params) ⇒ GlobalService

Returns a new instance of GlobalService


5
6
7
# File 'app/services/search/global_service.rb', line 5

def initialize(user, params)
  @current_user, @params = user, params.dup
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


3
4
5
# File 'app/services/search/global_service.rb', line 3

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params


3
4
5
# File 'app/services/search/global_service.rb', line 3

def params
  @params
end

Instance Method Details

#executeObject


9
10
11
12
13
14
15
# File 'app/services/search/global_service.rb', line 9

def execute
  group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
  projects = ProjectsFinder.new.execute(current_user)
  projects = projects.in_namespace(group.id) if group

  Gitlab::SearchResults.new(current_user, projects, params[:search])
end