Class: StarredProjectsFinder

Inherits:
ProjectsFinder show all
Includes:
Gitlab::Allowable
Defined in:
app/finders/starred_projects_finder.rb

Instance Attribute Summary

Attributes inherited from ProjectsFinder

#current_user, #params, #project_ids_relation

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Methods included from CustomAttributesFilter

#by_custom_attributes

Methods inherited from UnionFinder

#find_union

Constructor Details

#initialize(user, params: {}, current_user: nil) ⇒ StarredProjectsFinder

Returns a new instance of StarredProjectsFinder.


6
7
8
9
10
11
12
13
14
# File 'app/finders/starred_projects_finder.rb', line 6

def initialize(user, params: {}, current_user: nil)
  @user = user

  super(
    params: params,
    current_user: current_user,
    project_ids_relation: user.starred_projects.select(:id)
  )
end

Instance Method Details

#executeObject


16
17
18
19
20
21
# File 'app/finders/starred_projects_finder.rb', line 16

def execute
  # Do not show starred projects if the user has a private profile.
  return Project.none unless can?(current_user, :read_user_profile, @user)

  super
end