Class: PersonalProjectsFinder

Inherits:
UnionFinder show all
Includes:
Gitlab::Allowable
Defined in:
app/finders/personal_projects_finder.rb

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Methods inherited from UnionFinder

#find_union

Constructor Details

#initialize(user, params = {}) ⇒ PersonalProjectsFinder

Returns a new instance of PersonalProjectsFinder.


6
7
8
9
# File 'app/finders/personal_projects_finder.rb', line 6

def initialize(user, params = {})
  @user = user
  @params = params
end

Instance Method Details

#execute(current_user = nil) ⇒ Object

Finds the projects belonging to the user in “@user”, limited to either public projects or projects visible to the given user.

current_user - When given the list of projects is limited to those only

visible by this user.

params - Optional query parameters

min_access_level: integer

Returns an ActiveRecord::Relation.


20
21
22
23
24
25
26
# File 'app/finders/personal_projects_finder.rb', line 20

def execute(current_user = nil)
  return Project.none unless can?(current_user, :read_user_profile, @user)

  segments = all_projects(current_user)

  find_union(segments, Project).with_namespace.order_updated_desc
end