Class: ContributedProjectsFinder

Inherits:
UnionFinder show all
Defined in:
app/finders/contributed_projects_finder.rb

Instance Method Summary collapse

Methods inherited from UnionFinder

#find_union

Constructor Details

#initialize(user) ⇒ ContributedProjectsFinder

Returns a new instance of ContributedProjectsFinder.



4
5
6
# File 'app/finders/contributed_projects_finder.rb', line 4

def initialize(user)
  @user = user
end

Instance Method Details

#execute(current_user = nil, ignore_visibility: false) ⇒ Object

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

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

visible by this user.

ignore_visibility - When true the list of projects will include all contributed

projects, regardless of their visibility to the current_user

Returns an ActiveRecord::Relation.



18
19
20
21
22
23
24
25
# File 'app/finders/contributed_projects_finder.rb', line 18

def execute(current_user = nil, ignore_visibility: false)
  # Do not show contributed projects if the user profile is private.
  return Project.none unless can_read_profile?(current_user)

  segments = all_projects(current_user, ignore_visibility)

  find_union(segments, Project).with_namespace.order_id_desc
end